Пример #1
0
void show_ceos_meta_data(gchar * in_name)
{
#ifdef win32
    gchar * mdv = find_in_bin("mdv.exe");
#else
    gchar * mdv = find_in_bin("mdv");
#endif

    gchar * ceos_file = meta_file_name(in_name);

    // use_thumbnails should always be true here, since
    // we disable the option in the case where it is false
    if (mdv && use_thumbnails)
    {
#ifdef THUMBNAILS
        static GThreadPool *ttp = NULL;
        GError *err = NULL;

        if (!ttp)
        {
            // g_thread_init() no longer necessary as of Glib 2.32
#if ! (GLIB_MAJOR_VERSION > 2 || (GLIB_MINOR_VERSION >= 32))
            if (!g_thread_supported ()) g_thread_init (NULL);
#endif
            ttp = g_thread_pool_new ((GFunc) mdv_thread, NULL, 4, TRUE, &err);
            g_assert(!err);
        }
        g_thread_pool_push (ttp, g_string_new (ceos_file), &err);
        g_assert(!err);
#endif
    }
    else
    {
        message_box("Failed to open external metadata viewer!");
    }

    g_free (ceos_file);
}
Пример #2
0
static GdkWindow *
draw_popup_image (GtkWidget *widget, GtkTreePath *path,
                  GtkTreeViewColumn *column, GdkRegion *tr)
{
    g_assert (GTK_IS_TREE_VIEW (widget));
    g_assert (!GTK_WIDGET_NO_WINDOW (widget));

    /* We want to center the popup over the original thumbnail.  Since
    we know the original thumbnail is square, the clipbox corresponds
    to the region, so we can just get the clipbox of the thumbnail
    and take the center of that as the center of our popum image.  */
    GdkRectangle tn_rec;
    gdk_region_get_clipbox (tr, &tn_rec);

    /* Size of popup image to use, in pixels on a side.  */
    const gint popup_size = THUMB_SIZE_BIG;

    gint tree_view_x, tree_view_y;
    gdk_window_get_origin (widget->window, &tree_view_x, &tree_view_y);

    GdkWindowAttr nwa;
    nwa.event_mask = GDK_ALL_EVENTS_MASK;

    // popup must take into account any horizontal scrolling
    // that has taken place in the tree view
    GtkScrolledWindow *s =
       GTK_SCROLLED_WINDOW(get_widget_checked("scrolledwindow_in"));
    GtkAdjustment *adj = gtk_scrolled_window_get_hadjustment(s);
    gint h_adj = (gint)(.5 + gtk_adjustment_get_value(adj));

    // FIXME: when the pointer is over the popup itself,
    // maybe_clear_popup_image doesn't notice that we are still over the
    // thumbnail below and so clears things!  FIXME: I don't understand
    // why this code puts the popup image top left corner only halfway
    // down the thumbnail edge.  It looks fine this way actually, but as
    // I understand this code it should put popup top left at thumbnail
    // bottom right.
    nwa.x = tree_view_x + tn_rec.x + tn_rec.width - h_adj;
    nwa.y = tree_view_y + tn_rec.y + tn_rec.height;
    nwa.width = popup_size;
    nwa.height = popup_size;
    nwa.wclass = GDK_INPUT_OUTPUT;
    nwa.window_type = GDK_WINDOW_CHILD;
    nwa.override_redirect = TRUE;

    GdkWindow *root_window
        = gdk_screen_get_root_window (gdk_screen_get_default ());

    GdkWindow *popup_image_window
        = gdk_window_new (root_window, &nwa,
        GDK_WA_X | GDK_WA_Y | GDK_WA_NOREDIR);

    /* Iterator for the data in the current row of the list.  */
    GtkTreeIter iter;
    gtk_tree_model_get_iter (GTK_TREE_MODEL (list_store), &iter, path);

    char *file, *ancillary_file, *polsarpro_aux_info;
    gtk_tree_model_get (GTK_TREE_MODEL (list_store), &iter,
                        COL_INPUT_FILE, &file,
                        COL_ANCILLARY_FILE, &ancillary_file,
                        COL_POLSARPRO_INFO, &polsarpro_aux_info,
                        -1);

    char *metadata_file = meta_file_name (file);
    char *data_file = data_file_name (file);
    char *lut_basename = extract_lut_name(polsarpro_aux_info);

    if (is_polsarpro(file)) {
      if(strlen(metadata_file) > 0) {
	g_free(data_file);
	data_file = (gchar*)g_malloc(sizeof(gchar)*(strlen(metadata_file)));
	sprintf(data_file, "%s", metadata_file);
      }
      else {
	g_free(metadata_file);
	metadata_file = (gchar*)g_malloc(sizeof(gchar)*(strlen(data_file) + 5));
	sprintf(metadata_file, "%s%s", data_file, ".hdr");
      }
      if (!fileExists(metadata_file)) strcpy(metadata_file, "");
    }

    GdkPixbuf *popup_image_pixbuf
      = make_input_image_thumbnail_pixbuf (metadata_file, data_file, lut_basename,
                                           THUMB_SIZE_BIG);

    if (!popup_image_pixbuf && strlen(ancillary_file) > 0)
    {
        popup_image_pixbuf = make_input_image_thumbnail_pixbuf (
          ancillary_file, ancillary_file, lut_basename, THUMB_SIZE_BIG);          
    }

    g_free(file);
    g_free(ancillary_file);
    g_free(metadata_file);
    g_free(data_file);
    g_free(polsarpro_aux_info);
    free(lut_basename);

    if (popup_image_pixbuf)
    {
        gdk_window_show (popup_image_window);

        /* Magic number understood by gdk_draw_pixbuf to mean "use pixbuf
        width".  */
        const gint use_pixbuf_width = -1;
        gdk_draw_pixbuf (GDK_DRAWABLE (popup_image_window),
            NULL,
            popup_image_pixbuf,
            0, 0, 0, 0,
            use_pixbuf_width, use_pixbuf_width,
            GDK_RGB_DITHER_NONE,
            0, 0);

        g_object_unref (popup_image_pixbuf);

        return popup_image_window;
    }
    else
    {
        return NULL;
    }
}