⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gtkcontainer.c

📁 gtk是linux一款强大的夸平台的图形化开发工具
💻 C
📖 第 1 页 / 共 4 页
字号:
    {      g_warning ("gtk_container_arg_set(): argument \"%s\" has invalid type `%s'",		 info->full_name,		 gtk_type_name (arg->type));      return;    }    class = gtk_type_class (info->class_type);  g_assert (class->set_child_arg != NULL);  class->set_child_arg (container, child, arg, info->arg_id);}voidgtk_container_arg_get (GtkContainer *container,		       GtkWidget    *child,		       GtkArg       *arg,		       GtkArgInfo   *info){  GtkContainerClass *class;    g_return_if_fail (container != NULL);  g_return_if_fail (GTK_IS_CONTAINER (container));  g_return_if_fail (child != NULL);  g_return_if_fail (GTK_IS_WIDGET (child));  g_return_if_fail (arg != NULL);    if (!info)    {      gchar *error;            error = gtk_arg_get_info (GTK_OBJECT_TYPE (container),				container_child_arg_info_ht,				arg->name,				&info);      if (error)	{	  g_warning ("gtk_container_arg_get(): %s", error);	  g_free (error);	  arg->type = GTK_TYPE_INVALID;	  return;	}    }  g_return_if_fail (info->arg_flags & GTK_ARG_CHILD_ARG);    if (! (info->arg_flags & GTK_ARG_READABLE))    {      g_warning ("gtk_container_arg_get(): argument \"%s\" is not readable",		 info->full_name);      arg->type = GTK_TYPE_INVALID;      return;    }    class = gtk_type_class (info->class_type);  g_assert (class->get_child_arg != NULL);  arg->type = info->type;  class->get_child_arg (container, child, arg, info->arg_id);}voidgtk_container_add_child_arg_type (const gchar       *arg_name,				  GtkType            arg_type,				  guint              arg_flags,				  guint              arg_id){  g_return_if_fail (arg_name != NULL);  g_return_if_fail (arg_type > GTK_TYPE_NONE);  g_return_if_fail (arg_id > 0);  g_return_if_fail ((arg_flags & GTK_ARG_READWRITE) == GTK_ARG_READWRITE);  /* g_return_if_fail ((arg_flags & GTK_ARG_CHILD_ARG) != 0); */  arg_flags |= GTK_ARG_CHILD_ARG;  arg_flags &= GTK_ARG_MASK;  gtk_arg_type_new_static (GTK_TYPE_CONTAINER,			   arg_name,			   GTK_STRUCT_OFFSET (GtkContainerClass, n_child_args),			   container_child_arg_info_ht,			   arg_type,			   arg_flags,			   arg_id);}gchar*gtk_container_child_args_collect (GtkType       object_type,				  GSList      **arg_list_p,				  GSList      **info_list_p,				  const gchar  *first_arg_name,				  va_list	var_args){  return gtk_args_collect (object_type,			   container_child_arg_info_ht,			   arg_list_p,			   info_list_p,			   first_arg_name,			   var_args);}gchar*gtk_container_child_arg_get_info (GtkType       object_type,				  const gchar  *arg_name,				  GtkArgInfo  **info_p){  return gtk_arg_get_info (object_type,			   container_child_arg_info_ht,			   arg_name,			   info_p);}GtkArg*gtk_container_query_child_args (GtkType	           class_type,				guint32          **arg_flags,				guint             *n_args){  g_return_val_if_fail (n_args != NULL, NULL);  *n_args = 0;  g_return_val_if_fail (gtk_type_is_a (class_type, GTK_TYPE_CONTAINER), NULL);  return gtk_args_query (class_type, container_child_arg_info_ht, arg_flags, n_args);}static voidgtk_container_add_unimplemented (GtkContainer     *container,				 GtkWidget        *widget){  g_warning ("GtkContainerClass::add not implemented for `%s'", gtk_type_name (GTK_OBJECT_TYPE (container)));}static voidgtk_container_remove_unimplemented (GtkContainer     *container,				    GtkWidget        *widget){  g_warning ("GtkContainerClass::remove not implemented for `%s'", gtk_type_name (GTK_OBJECT_TYPE (container)));}static voidgtk_container_init (GtkContainer *container){  container->focus_child = NULL;  container->border_width = 0;  container->need_resize = FALSE;  container->resize_mode = GTK_RESIZE_PARENT;  container->reallocate_redraws = FALSE;  container->resize_widgets = NULL;}static voidgtk_container_destroy (GtkObject *object){  GtkContainer *container;  g_return_if_fail (object != NULL);  g_return_if_fail (GTK_IS_CONTAINER (object));  container = GTK_CONTAINER (object);    if (GTK_CONTAINER_RESIZE_PENDING (container))    gtk_container_dequeue_resize_handler (container);  if (container->resize_widgets)    gtk_container_clear_resize_widgets (container);    gtk_container_foreach (container, (GtkCallback) gtk_widget_destroy, NULL);    if (GTK_OBJECT_CLASS (parent_class)->destroy)    (* GTK_OBJECT_CLASS (parent_class)->destroy) (object);}static voidgtk_container_set_arg (GtkObject    *object,		       GtkArg       *arg,		       guint	     arg_id){  GtkContainer *container;  container = GTK_CONTAINER (object);  switch (arg_id)    {    case ARG_BORDER_WIDTH:      gtk_container_set_border_width (container, GTK_VALUE_ULONG (*arg));      break;    case ARG_RESIZE_MODE:      gtk_container_set_resize_mode (container, GTK_VALUE_ENUM (*arg));      break;    case ARG_REALLOCATE_REDRAWS:      gtk_container_set_reallocate_redraws (container, GTK_VALUE_BOOL (*arg));      break;    case ARG_CHILD:      gtk_container_add (container, GTK_WIDGET (GTK_VALUE_OBJECT (*arg)));      break;    default:      break;    }}static voidgtk_container_get_arg (GtkObject    *object,		       GtkArg       *arg,		       guint	     arg_id){  GtkContainer *container;  container = GTK_CONTAINER (object);    switch (arg_id)    {    case ARG_BORDER_WIDTH:      GTK_VALUE_ULONG (*arg) = container->border_width;      break;    case ARG_RESIZE_MODE:      GTK_VALUE_ENUM (*arg) = container->resize_mode;      break;    case ARG_REALLOCATE_REDRAWS:      GTK_VALUE_BOOL (*arg) = container->reallocate_redraws;      break;    default:      arg->type = GTK_TYPE_INVALID;      break;    }}voidgtk_container_set_border_width (GtkContainer *container,				guint         border_width){  g_return_if_fail (container != NULL);  g_return_if_fail (GTK_IS_CONTAINER (container));  if (container->border_width != border_width)    {      container->border_width = border_width;      if (GTK_WIDGET_REALIZED (container))	gtk_widget_queue_resize (GTK_WIDGET (container));    }}voidgtk_container_add (GtkContainer *container,		   GtkWidget    *widget){  g_return_if_fail (container != NULL);  g_return_if_fail (GTK_IS_CONTAINER (container));  g_return_if_fail (widget != NULL);  g_return_if_fail (GTK_IS_WIDGET (widget));  g_return_if_fail (widget->parent == NULL);  if (!GTK_OBJECT_CONSTRUCTED (widget))    gtk_object_default_construct (GTK_OBJECT (widget));  gtk_signal_emit (GTK_OBJECT (container), container_signals[ADD], widget);}voidgtk_container_remove (GtkContainer *container,		      GtkWidget    *widget){  g_return_if_fail (container != NULL);  g_return_if_fail (GTK_IS_CONTAINER (container));  g_return_if_fail (widget != NULL);  g_return_if_fail (GTK_IS_WIDGET (widget));  g_return_if_fail (widget->parent == GTK_WIDGET (container));    gtk_signal_emit (GTK_OBJECT (container), container_signals[REMOVE], widget);}voidgtk_container_dequeue_resize_handler (GtkContainer *container){  g_return_if_fail (GTK_IS_CONTAINER (container));  g_return_if_fail (GTK_CONTAINER_RESIZE_PENDING (container));  container_resize_queue = g_slist_remove (container_resize_queue, container);  GTK_PRIVATE_UNSET_FLAG (container, GTK_RESIZE_PENDING);}voidgtk_container_clear_resize_widgets (GtkContainer *container){  GSList *node;  g_return_if_fail (container != NULL);  g_return_if_fail (GTK_IS_CONTAINER (container));  node = container->resize_widgets;  while (node)    {      GtkWidget *widget = node->data;      GTK_PRIVATE_UNSET_FLAG (widget, GTK_RESIZE_NEEDED);      node = node->next;    }    g_slist_free (container->resize_widgets);  container->resize_widgets = NULL;}voidgtk_container_set_resize_mode (GtkContainer  *container,			       GtkResizeMode  resize_mode){  g_return_if_fail (container != NULL);  g_return_if_fail (GTK_IS_CONTAINER (container));  g_return_if_fail (resize_mode <= GTK_RESIZE_IMMEDIATE);    if (GTK_WIDGET_TOPLEVEL (container) &&      resize_mode == GTK_RESIZE_PARENT)    resize_mode = GTK_RESIZE_QUEUE;    if (container->resize_mode != resize_mode)    {      container->resize_mode = resize_mode;            if (resize_mode == GTK_RESIZE_IMMEDIATE)	gtk_container_check_resize (container);      else	{	  gtk_container_clear_resize_widgets (container);	  gtk_widget_queue_resize (GTK_WIDGET (container));	}    }}voidgtk_container_set_reallocate_redraws (GtkContainer *container,				      gboolean      needs_redraws){  g_return_if_fail (GTK_IS_CONTAINER (container));  needs_redraws = needs_redraws ? TRUE : FALSE;  if (needs_redraws != container->reallocate_redraws)    {      container->reallocate_redraws = needs_redraws;      if (container->reallocate_redraws)	gtk_widget_queue_draw (GTK_WIDGET (container));    }}static GtkContainer*gtk_container_get_resize_container (GtkContainer *container){  GtkWidget *widget;  widget = GTK_WIDGET (container);  while (widget->parent)    {      widget = widget->parent;      if (GTK_IS_RESIZE_CONTAINER (widget) && !GTK_WIDGET_RESIZE_NEEDED (widget))	break;    }  return GTK_IS_RESIZE_CONTAINER (widget) ? (GtkContainer*) widget : NULL;}static gbooleangtk_container_idle_sizer (gpointer data){  GDK_THREADS_ENTER ();  /* we may be invoked with a container_resize_queue of NULL, because   * queue_resize could have been adding an extra idle function while   * the queue still got processed. we better just ignore such case   * than trying to explicitely work around them with some extra flags,   * since it doesn't cause any actual harm.   */  while (container_resize_queue)    {      GSList *slist;      GtkWidget *widget;      slist = container_resize_queue;      container_resize_queue = slist->next;      widget = slist->data;      g_slist_free_1 (slist);      GTK_PRIVATE_UNSET_FLAG (widget, GTK_RESIZE_PENDING);      gtk_container_check_resize (GTK_CONTAINER (widget));    }  GDK_THREADS_LEAVE ();    return FALSE;}voidgtk_container_queue_resize (GtkContainer *container){  GtkContainer *resize_container;    g_return_if_fail (container != NULL);  g_return_if_fail (GTK_IS_CONTAINER (container));  /* clear resize widgets for resize containers   * before aborting prematurely. this is especially   * important for toplevels which may need imemdiate   * processing or their resize handler to be queued.   */  if (GTK_IS_RESIZE_CONTAINER (container))    gtk_container_clear_resize_widgets (container);  if (GTK_OBJECT_DESTROYED (container) ||      GTK_WIDGET_RESIZE_NEEDED (container))    return;    resize_container = gtk_container_get_resize_container (container);    if (resize_container)    {      if (GTK_WIDGET_DRAWABLE (resize_container))	{	  switch (resize_container->resize_mode)	    {	    case GTK_RESIZE_QUEUE:	      if (!GTK_CONTAINER_RESIZE_PENDING (resize_container))		{		  GTK_PRIVATE_SET_FLAG (resize_container, GTK_RESIZE_PENDING);		  if (container_resize_queue == NULL)		    gtk_idle_add_priority (GTK_PRIORITY_RESIZE,					   gtk_container_idle_sizer,					   NULL);		  container_resize_queue = g_slist_prepend (container_resize_queue, resize_container);		}	      	      GTK_PRIVATE_SET_FLAG (container, GTK_RESIZE_NEEDED);	      resize_container->resize_widgets =		g_slist_prepend (resize_container->resize_widgets, container);	      break;	    case GTK_RESIZE_IMMEDIATE:	      GTK_PRIVATE_SET_FLAG (container, GTK_RESIZE_NEEDED);	      resize_container->resize_widgets =		g_slist_prepend (resize_container->resize_widgets, container);	      gtk_container_check_resize (resize_container);	      break;	    case GTK_RESIZE_PARENT:	      /* Ignore, should not be reached */	      break;	    }	}      else	{	  /* we need to let hidden resize containers know that something	   * changed while they where hidden (currently only evaluated by	   * toplevels).	   */	  resize_container->need_resize = TRUE;	}    }}voidgtk_container_check_resize (GtkContainer *container){  g_return_if_fail (container != NULL);  g_return_if_fail (GTK_IS_CONTAINER (container));    gtk_signal_emit (GTK_OBJECT (container), container_signals[CHECK_RESIZE]);}static voidgtk_container_real_check_resize (GtkContainer *container){  GtkWidget *widget;  GtkRequisition requisition;    g_return_if_fail (container != NULL);  g_return_if_fail (GTK_IS_CONTAINER (container));  

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -