示例#1
0
/******************************************************
 *                   Project Callbacks                *
 ******************************************************/
static void
project_targets_changed (GladeProject           *project,
			 GladeProjectProperties *properties)
{
  GladeProjectPropertiesPrivate *priv = properties->priv;
  GList *list;
  GSList *radios, *l;

  priv->ignore_ui_cb = TRUE;

  /* For each catalog */
  for (list = glade_app_get_catalogs (); list; list = g_list_next (list))
    {
      GladeTargetableVersion *version;
      GladeCatalog *catalog = list->data;
      gint minor, major;

      /* Skip if theres only one option */
      if (g_list_length (glade_catalog_get_targets (catalog)) <= 1)
        continue;

      /* Fetch the version for this project */
      glade_project_get_target_version (priv->project,
                                        glade_catalog_get_name (catalog),
                                        &major, &minor);

      /* Fetch the radios for this catalog  */
      if (priv->target_radios &&
	  (radios = g_hash_table_lookup (priv->target_radios, glade_catalog_get_name (catalog))) != NULL)
	{
	  for (l = radios; l; l = l->next)
	    {
	      GtkWidget *radio = l->data;

	      /* Activate the appropriate button for the project/catalog */
	      version = g_object_get_data (G_OBJECT (radio), "version");
	      if (version->major == major && version->minor == minor)
		{
		  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), TRUE);
		  break;
		}
	    }
	}
    }
  priv->ignore_ui_cb = FALSE;
}
示例#2
0
GladeCatalog *
glade_app_get_catalog (const gchar *name)
{
  GladeApp *app = glade_app_get ();
  GList *list;
  GladeCatalog *catalog;

  g_return_val_if_fail (name && name[0], NULL);

  for (list = app->priv->catalogs; list; list = list->next)
    {
      catalog = list->data;
      if (!strcmp (glade_catalog_get_name (catalog), name))
        return catalog;
    }
  return NULL;
}
示例#3
0
static void
target_version_box_fill (GladeProjectProperties *properties)
{
  GladeProjectPropertiesPrivate *priv = properties->priv;
  GladeProject *project = priv->project;
  GtkWidget *vbox = priv->toolkit_box;
  GtkWidget *label, *active_radio, *target_radio, *hbox;
  GList *list, *targets;

  /* Add stuff to vbox */
  for (list = glade_app_get_catalogs (); list; list = g_list_next (list))
    {
      GladeCatalog *catalog = list->data;
      gint minor, major;

      /* Skip if theres only one option */
      if (g_list_length (glade_catalog_get_targets (catalog)) <= 1)
        continue;

      glade_project_get_target_version (project,
                                        glade_catalog_get_name (catalog),
                                        &major, &minor);

      /* Special case to mark GTK+ in upper case */
      if (strcmp (glade_catalog_get_name (catalog), "gtk+") == 0)
        label = gtk_label_new ("GTK+");
      else
        label = gtk_label_new (glade_catalog_get_name (catalog));
      gtk_misc_set_alignment (GTK_MISC (label), 0.0F, 0.5F);

      gtk_widget_show (label);
      gtk_box_pack_start (GTK_BOX (vbox), label, TRUE, TRUE, 2);
      hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);

      active_radio = target_radio = NULL;

      for (targets = glade_catalog_get_targets (catalog);
           targets; targets = targets->next)
        {
          GladeTargetableVersion *version = targets->data;
          gchar *name = g_strdup_printf ("%d.%d",
                                         version->major,
                                         version->minor);

          if (!target_radio)
            target_radio = gtk_radio_button_new_with_label (NULL, name);
          else
            target_radio =
                gtk_radio_button_new_with_label_from_widget
                (GTK_RADIO_BUTTON (target_radio), name);
          g_free (name);

          g_signal_connect (G_OBJECT (target_radio), "clicked",
                            G_CALLBACK (target_button_clicked), properties);

          g_object_set_data (G_OBJECT (target_radio), "version", version);
          g_object_set_data (G_OBJECT (target_radio), "catalog",
                             (gchar *) glade_catalog_get_name (catalog));

          gtk_widget_show (target_radio);
          gtk_box_pack_end (GTK_BOX (hbox), target_radio, TRUE, TRUE, 2);

          if (major == version->major && minor == version->minor)
            active_radio = target_radio;

        }

      if (active_radio)
        {
          gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (active_radio), TRUE);
          g_hash_table_insert (priv->target_radios,
                               g_strdup (glade_catalog_get_name (catalog)),
                               gtk_radio_button_get_group (GTK_RADIO_BUTTON
                                                           (active_radio)));
        }
      else
        g_warning ("Corrupt catalog versions");

      gtk_widget_show (hbox);
      gtk_box_pack_start (GTK_BOX (vbox), hbox, TRUE, TRUE, 2);
    }
}