コード例 #1
0
ファイル: go-combo-box.c プロジェクト: Distrotech/abiword
/**
 * go_combo_popup_reparent
 * @popup:       Popup
 * @new_parent:  New parent
 * @unrealize:   Unrealize popup if TRUE.
 *
 * Reparent the popup, taking care of the refcounting
 *
 * Compare with gtk_menu_reparent in gtk/gtkmenu.c
 */
static void
go_combo_popup_reparent (GtkWidget *popup,
			 GtkWidget *new_parent,
			 gboolean unrealize)
{
#if GLIB_CHECK_VERSION(2,10,0) && GTK_CHECK_VERSION(2,8,14)
	gboolean was_floating = g_object_is_floating (popup);
	g_object_ref_sink (popup);
#else
	gboolean was_floating = GTK_OBJECT_FLOATING (popup);
	g_object_ref (popup);
	gtk_object_sink (GTK_OBJECT (popup));
#endif

	if (unrealize) {
		g_object_ref (popup);
		gtk_container_remove (GTK_CONTAINER (popup->parent), popup);
		gtk_container_add (GTK_CONTAINER (new_parent), popup);
		g_object_unref (popup);
	}
	else
		gtk_widget_reparent (GTK_WIDGET (popup), new_parent);
	gtk_widget_set_size_request (new_parent, -1, -1);

	if (was_floating) {
#if GLIB_CHECK_VERSION(2,10,0) && GTK_CHECK_VERSION(2,8,14)
		g_object_force_floating (G_OBJECT (popup));
#else
		GTK_OBJECT_SET_FLAGS (GTK_OBJECT (popup), GTK_FLOATING);
#endif
	} else
		g_object_unref (popup);
}
コード例 #2
0
static void 
xml_start (GMarkupParseContext *context,
           const gchar         *element_name,
           const gchar         **attribute_names,
           const gchar         **attribute_values,
           gpointer             data,
           GError              **error)
{
  XmlData *xml_data = data;
  const gchar** names = attribute_names;
  const gchar** values = attribute_values;
  
  if (g_strcmp0 (element_name, (gchar*)xml_data->name) == 0)
    {
      GObject *object;
      object = g_object_new (xml_data->type, NULL);
      
      for (; *names; names++, values++)
        {
          GType *type;
          type = g_hash_table_lookup (xml_data->args, *names);
          if (type != NULL) /*here for backwards compatibility with file format change*/
            {
              if (*type == G_TYPE_STRING)
                {
                  gchar *quot;
                  gchar *apos;
                  gchar *lt;
                  gchar *gt;
                  gchar *amp;
                  quot = codeslayer_utils_strreplace (*values, """, "\"");
                  apos = codeslayer_utils_strreplace (quot, "'", "'");
                  lt = codeslayer_utils_strreplace (apos, "&lt;", "<");
                  gt = codeslayer_utils_strreplace (lt, "&gt;", ">");
                  amp = codeslayer_utils_strreplace (gt, "&amp;", "&");
                  
                  g_object_set (object, *names, amp, NULL);
                  g_free (quot);
                  g_free (apos);
                  g_free (lt);
                  g_free (gt);
                  g_free (amp);
                }
              else if (*type == G_TYPE_BOOLEAN || *type == G_TYPE_INT)
                {
                  g_object_set (object, *names, atoi(*values), NULL);
                }
            }
        }
        
      if (xml_data->floating)
        g_object_force_floating (object);        
        
      xml_data->list = g_list_prepend (xml_data->list, object);
    }
}
コード例 #3
0
void test_float_sink()
{
	 GTest *test;
	 GObject* obj;
	 test = g_object_new (G_TYPE_TEST, NULL);
	 obj = G_OBJECT(test);
	 g_object_force_floating(obj);
	 g_assert(g_object_is_floating(obj));
	 g_object_ref_sink(obj);
	 g_object_unref(obj);
}
コード例 #4
0
ファイル: gimpitem.c プロジェクト: jdburton/gimp-osx
static void
gimp_item_init (GimpItem *item)
{
  g_object_force_floating (G_OBJECT (item));

  item->ID        = 0;
  item->tattoo    = 0;
  item->image     = NULL;
  item->parasites = gimp_parasite_list_new ();
  item->width     = 0;
  item->height    = 0;
  item->offset_x  = 0;
  item->offset_y  = 0;
  item->visible   = TRUE;
  item->linked    = FALSE;
  item->removed   = FALSE;
}
コード例 #5
0
static void
hildon_app_menu_init                            (HildonAppMenu *menu)
{
    GtkWidget *alignment;
    HildonAppMenuPrivate *priv = HILDON_APP_MENU_GET_PRIVATE(menu);

    /* Initialize private variables */
    priv->parent_window = NULL;
    priv->transfer_window = NULL;
    priv->pressed_outside = FALSE;
    priv->inhibit_repack = FALSE;
    priv->last_pressed_button = NULL;
    priv->buttons = NULL;
    priv->filters = NULL;
    priv->columns = 2;
    priv->width_request = -1;
    priv->find_intruder_idle_id = 0;
    priv->hide_idle_id = 0;

    /* Create boxes and tables */
    priv->filters_hbox = GTK_BOX (gtk_hbox_new (TRUE, 0));
    priv->vbox = GTK_BOX (gtk_vbox_new (FALSE, 0));
    priv->table = GTK_TABLE (gtk_table_new (1, priv->columns, TRUE));

    /* Align the filters to the center */
    alignment = gtk_alignment_new (0.5, 0.5, 0, 0);
    gtk_container_add (GTK_CONTAINER (alignment), GTK_WIDGET (priv->filters_hbox));

    /* Pack everything */
    gtk_container_add (GTK_CONTAINER (menu), GTK_WIDGET (priv->vbox));
    gtk_box_pack_start (priv->vbox, alignment, TRUE, TRUE, 0);
    gtk_box_pack_start (priv->vbox, GTK_WIDGET (priv->table), TRUE, TRUE, 0);

    /* This should be treated like a normal, ref-counted widget */
    g_object_force_floating (G_OBJECT (menu));
    GTK_WINDOW (menu)->has_user_ref_count = FALSE;

    gtk_widget_show_all (GTK_WIDGET (priv->vbox));
}
コード例 #6
0
ファイル: sheet.c プロジェクト: hriesz/oregano-old
void
sheet_clear_ghosts (Sheet *sheet)
{
	GList *copy, *list;
	
	g_return_if_fail (sheet != NULL);
	g_return_if_fail (IS_SHEET (sheet));

	if (sheet->priv->floating_objects == NULL) return;

	g_assert (sheet->state != SHEET_STATE_FLOAT);
	copy = g_list_copy (sheet->priv->floating_objects);

	for (list = copy; list; list = list->next) {
		g_object_force_floating (G_OBJECT (list->data));
		g_object_unref (G_OBJECT (list->data));
	}

	g_list_free (copy);
	
	sheet->priv->floating_objects = NULL;
}
コード例 #7
0
/**
 * go_combo_popup_reparent
 * @popup:       Popup
 * @new_parent:  New parent
 * @unrealize:   Unrealize popup if TRUE.
 *
 * Reparent the popup, taking care of the refcounting
 *
 * Compare with gtk_menu_reparent in gtk/gtkmenu.c
 */
static void
go_combo_popup_reparent (GtkWidget *popup,
			 GtkWidget *new_parent,
			 gboolean unrealize)
{
	gboolean was_floating = g_object_is_floating (popup);
	g_object_ref_sink (popup);

	if (unrealize) {
		g_object_ref (popup);
		gtk_container_remove (GTK_CONTAINER (gtk_widget_get_parent (popup)), popup);
		gtk_container_add (GTK_CONTAINER (new_parent), popup);
		g_object_unref (popup);
	}
	else
		gtk_widget_reparent (GTK_WIDGET (popup), new_parent);
	gtk_widget_set_size_request (new_parent, -1, -1);

	if (was_floating) {
		g_object_force_floating (G_OBJECT (popup));
	} else
		g_object_unref (popup);
}