Exemplo n.º 1
0
/*
 * Writes the source code needed to create this widget.
 * You have to output everything necessary to create the widget here, though
 * there are some convenience functions to help.
 */
static void
gb_menu_item_write_source (GtkWidget * widget, GbWidgetWriteSourceData * data)
{
  GtkWidget *child = GTK_BIN (widget)->child;
  gchar *label_text;
  gboolean translatable, context;
  gchar *comments;

#ifdef USE_GNOME
  if (data->project->gnome_support)
    {
      glade_gnome_write_menu_item_source (GTK_MENU_ITEM (widget), data);
      return;
    }
#endif

  if (child && GTK_IS_LABEL (child) && !GB_IS_GB_WIDGET (child))
    {
      glade_util_get_translation_properties (widget, Label, &translatable,
					     &comments, &context);
      source_add_translator_comments (data, translatable, comments);

      label_text = glade_util_get_label_text (child);
      source_add (data, "  %s = gtk_menu_item_new_with_mnemonic (%s);\n",
		  data->wname,
		  source_make_string_full (label_text, data->use_gettext && translatable, context));
      g_free (label_text);
    }
  else
    {
      source_add (data, "  %s = gtk_menu_item_new ();\n", data->wname);
    }

  gb_widget_write_standard_source (widget, data);
}
Exemplo n.º 2
0
/*
 * Writes the source code needed to create this widget.
 * You have to output everything necessary to create the widget here, though
 * there are some convenience functions to help.
 */
static void
gb_list_item_write_source (GtkWidget * widget, GbWidgetWriteSourceData * data)
{
  GtkWidget *child = GTK_BIN (widget)->child;
  const gchar *label_text;
  gboolean translatable, context;
  gchar *comments;

  if (data->create_widget)
    {
      if (child && GTK_IS_LABEL (child) && !GB_IS_GB_WIDGET (child))
	{
	  glade_util_get_translation_properties (widget, Label, &translatable,
						 &comments, &context);
	  source_add_translator_comments (data, translatable, comments);

	  label_text = gtk_label_get_text (GTK_LABEL (child));
	  source_add (data, "  %s = gtk_list_item_new_with_label (%s);\n",
		      data->wname,
		      source_make_string_full (label_text, data->use_gettext && translatable, context));
	}
      else
	{
	  source_add (data, "  %s = gtk_list_item_new ();\n", data->wname);
	}
    }

  gb_widget_write_standard_source (widget, data);
}
Exemplo n.º 3
0
static void
find_radio_group (GtkWidget *widget, GladeFindGroupData *find_data)
{
  if (find_data->found_widget)
    return;

  if (GTK_IS_RADIO_TOOL_BUTTON (widget) && GB_IS_GB_WIDGET (widget))
    {
      if (gtk_radio_tool_button_get_group (GTK_RADIO_TOOL_BUTTON (widget)) == find_data->group)
	{
	  find_data->found_widget = widget;
	}
    }
}
Exemplo n.º 4
0
static void
find_group_widget (GtkWidget *widget, GladeFindGroupWidgetData *find_data)
{
  if (find_data->found_widget)
    return;

  if (GTK_IS_RADIO_TOOL_BUTTON (widget) && GB_IS_GB_WIDGET (widget))
    {
      if (!strcmp (gtk_widget_get_name (widget), find_data->name))
	{
#if 0
	  g_print ("Found widget: %s\n", find_data->name);
#endif
	  find_data->found_widget = widget;
	}
    }
}
Exemplo n.º 5
0
static void
gb_label_get_focus_targets (GtkWidget * widget,
			    GList ** focus_targets)
{
  if (GTK_WIDGET_CAN_FOCUS (widget) && GB_IS_GB_WIDGET (widget))
    {
      *focus_targets = g_list_insert_sorted (*focus_targets,
					     (gchar*) gtk_widget_get_name (widget),
					     g_str_equal);
    }

  if (GTK_IS_CONTAINER (widget))
    {
      gtk_container_forall (GTK_CONTAINER (widget),
			    (GtkCallback) gb_label_get_focus_targets,
			    focus_targets);
    }
}
Exemplo n.º 6
0
/* Note that this must walk the widget tree in exactly the same way that we
   save the widgets, so we know which widget in the group will be the first
   output. */
static void
get_radio_button_groups (GtkWidget * widget, GladeFindGroupsData *find_data)
{
  if (GTK_IS_RADIO_TOOL_BUTTON (widget) && GB_IS_GB_WIDGET (widget))
    {
      GSList *group = gtk_radio_tool_button_get_group (GTK_RADIO_TOOL_BUTTON (widget));

      /* See if we've already found a widget in this group. */
      if (!g_list_find (find_data->groups_found, group))
	{
	  const char *name = gtk_widget_get_name (GTK_WIDGET (widget));

	  /* Remember that we've already seen this group. */
	  find_data->groups_found = g_list_prepend (find_data->groups_found,
						    group);

	  /* Add the widget's name to the list. */
	  find_data->group_names = g_list_insert_sorted (find_data->group_names, (char*)name, (GCompareFunc) g_utf8_collate);
	}
    }
}
Exemplo n.º 7
0
/*
 * Writes the source code needed to create this widget.
 * You have to output everything necessary to create the widget here, though
 * there are some convenience functions to help.
 */
static void
gb_radio_button_write_source (GtkWidget * widget, GbWidgetWriteSourceData * data)
{
  GtkWidget *child = GTK_BUTTON (widget)->child;
  gchar *label_text;
  gchar buffer[256];

  gchar *group_name = gtk_object_get_data (GTK_OBJECT (widget), Group);
  if (!group_name)
    group_name = gtk_widget_get_name (widget->parent);

  if (data->create_widget)
    {
      if (gb_toolbar_is_toolbar_button (widget))
	{
	  gb_toolbar_write_toolbar_button_source (widget, data);
	}
      else
	{
	  /* Make sure the temporary group list variable is declared. */
	  group_name = source_create_valid_identifier (group_name);
	  sprintf (buffer, "  GSList *%s_group = NULL;\n", group_name);
	  source_ensure_decl (data, buffer);

	  if (child && GTK_IS_LABEL (child) && !GB_IS_GB_WIDGET (child))
	    {
	      label_text = glade_util_get_label_text (GTK_BIN (widget)->child);
	      /* If there is an underlined accelerator, set up the signal. */
	      if (strchr (label_text, '_'))
		{
		  source_add (data,
			      "  %s = gtk_radio_button_new_with_label (%s_group, \"\");\n",
			      data->wname, group_name);
		  gb_button_write_uline_accel_source (widget, data,
						      label_text);
		}
	      else
		{
		  source_add (data,
			      "  %s = gtk_radio_button_new_with_label (%s_group, %s);\n",
			      data->wname, group_name,
			      source_make_string (label_text,
						  data->use_gettext));
		}
	      g_free (label_text);
	    }
	  else
	    {
	      source_add (data, "  %s = gtk_radio_button_new (%s_group);\n",
			  data->wname, group_name);
	    }
	  source_add (data,
		      "  %s_group = gtk_radio_button_group (GTK_RADIO_BUTTON (%s));\n",
		      group_name, data->wname);
	  g_free (group_name);
	}
    }
  gb_widget_write_standard_source (widget, data);

  if (data->widget_data->flags & GLADE_ACTIVE)
    {
      source_add (data,
	  "  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (%s), TRUE);\n",
		  data->wname);
    }
  if (!GTK_TOGGLE_BUTTON (widget)->draw_indicator)
    {
      source_add (data,
	  "  gtk_toggle_button_set_mode (GTK_TOGGLE_BUTTON (%s), FALSE);\n",
		  data->wname);
    }
}