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

📄 gsegyensembleselect.c

📁 segy 显示程序!希望能给正在做这部分朋友提供一部分资料
💻 C
📖 第 1 页 / 共 2 页
字号:
/*  * GTKSEISVIEWUI - Library of interface elements for GSEGYView * * Copyright (C) 2006 Vladimir Bashkardin * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU * General Public License for more av. * * You should have received a copy of the GNU General Public * License along with this program; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. * * Author:  Vladimir Bashkardin  <vovizmus@users.sourceforge.net> */#include "gsegyfileaux.h"#include "gsegyfileui_marshal.h"#include "gsegyensembleselect.h"#define MIN_ANIMATION_DELAY 250G_DEFINE_TYPE (GSEGYEnsembleSelect, g_segy_ensemble_select, G_TYPE_OBJECT)#define G_SEGY_ENSEMBLE_SELECT_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), G_SEGY_TYPE_ENSEMBLE_SELECT, GSEGYEnsembleSelectPrivate))typedef struct _GSEGYEnsembleSelectPrivate GSEGYEnsembleSelectPrivate;struct _GSEGYEnsembleSelectPrivate {    GtkWidget *handle;    GtkWidget *vbox;    GtkWidget *hbox;    GtkWidget *backward_ensemble_button;    GtkWidget *backward_ensemble_icon;    GtkWidget *previous_ensemble_button;    GtkWidget *previous_ensemble_icon;    GtkWidget *stop_ensemble_button;    GtkWidget *stop_ensemble_icon;    GtkWidget *next_ensemble_button;    GtkWidget *next_ensemble_icon;    GtkWidget *forward_ensemble_button;    GtkWidget *forward_ensemble_icon;    GtkWidget *animation_delay_frame;    GtkWidget *animation_delay_vbox;    GtkWidget *animation_delay_scale;    GtkTooltips     *ensemble_select_tips;    GtkWidget       *scrolled_window;    GtkWidget       *tree_view;    GtkListStore    *ensemble_list_store;    GtkCellRenderer *ensemble_cell_renderer;    gint             list_selection;    gboolean         block_selection;    GTimer          *animation_timer;    gdouble          time_elapsed;    gboolean         stop_animation;    gboolean         restart_animation;    gboolean         forward_animation;    guint            animation_delay;    guint            animation_timeout_source;    GPtrArray       *labels;    GdkCursor       *watch_cursor;};static void g_segy_ensemble_select_init (GSEGYEnsembleSelect *self) {    GSEGYEnsembleSelectPrivate *private = G_SEGY_ENSEMBLE_SELECT_GET_PRIVATE (self);    private->handle = NULL;    private->vbox = NULL;    private->hbox = NULL;    private->backward_ensemble_button = NULL;    private->backward_ensemble_icon = NULL;    private->previous_ensemble_button = NULL;    private->previous_ensemble_icon = NULL;    private->stop_ensemble_button = NULL;    private->stop_ensemble_icon = NULL;    private->next_ensemble_button = NULL;    private->next_ensemble_icon = NULL;    private->forward_ensemble_button = NULL;    private->forward_ensemble_icon = NULL;    private->animation_delay_frame = NULL;    private->animation_delay_vbox = NULL;    private->animation_delay_scale = NULL;    private->ensemble_select_tips = NULL;    private->scrolled_window = NULL;    private->tree_view = NULL;    private->ensemble_list_store = NULL;    private->ensemble_cell_renderer = NULL;    private->list_selection = 0;    private->block_selection = FALSE;    private->animation_delay = MIN_ANIMATION_DELAY;    private->stop_animation = TRUE;    private->restart_animation = FALSE;    private->forward_animation = TRUE;    private->time_elapsed = 0;    private->animation_timeout_source = 0;    private->animation_timer = g_timer_new ();    private->labels = NULL;    private->watch_cursor = gdk_cursor_new (GDK_WATCH);#ifdef DEBUG    g_print ("<GSEGYEnsembleSelect is inited>\n");#endif}static void g_segy_ensemble_select_finalize (GObject *object) {    GSEGYEnsembleSelect *self = G_SEGY_ENSEMBLE_SELECT (object);    GSEGYEnsembleSelectPrivate *private = G_SEGY_ENSEMBLE_SELECT_GET_PRIVATE (self);    while (g_idle_remove_by_data ((gpointer)self));    if (private->animation_timeout_source)        g_source_remove (private->animation_timeout_source);    if (private->vbox) {        gtk_widget_destroy (private->handle);        g_object_unref (G_OBJECT (private->ensemble_list_store));    }    if (private->watch_cursor)        gdk_cursor_unref (private->watch_cursor);    if (private->animation_timer)        g_timer_destroy (private->animation_timer);    if (private->ensemble_select_tips)        g_object_unref (G_OBJECT (private->ensemble_select_tips));#ifdef DEBUG    g_print ("<GSEGYEnsembleSelect is finalized>\n");#endif    if (G_OBJECT_CLASS (g_segy_ensemble_select_parent_class)->finalize)        G_OBJECT_CLASS (g_segy_ensemble_select_parent_class)->finalize (object);}static void g_segy_ensemble_select_class_init (GSEGYEnsembleSelectClass *klass) {    GObjectClass *gobject_class = G_OBJECT_CLASS (klass);    gobject_class->finalize = g_segy_ensemble_select_finalize;    g_type_class_add_private (klass, sizeof (GSEGYEnsembleSelectPrivate));    klass->ensemble_select = NULL;    klass->ensemble_select_id = g_signal_new ("ensemble_select",                                              G_TYPE_FROM_CLASS ((gpointer)G_OBJECT_CLASS (klass)),                                              G_SIGNAL_RUN_LAST,                                              G_STRUCT_OFFSET (GSEGYEnsembleSelectClass, ensemble_select),                                              NULL, NULL,                                              g_segyui_marshal_VOID__INT,                                              G_TYPE_NONE, 1, G_TYPE_INT);#ifdef DEBUG    g_print ("<GSEGYEnsembleSelect class is inited>\n");#endif}void g_segy_ensemble_select_enable (GSEGYEnsembleSelect *self) {    GSEGYEnsembleSelectPrivate *private = G_SEGY_ENSEMBLE_SELECT_GET_PRIVATE (self);    private->block_selection = FALSE;    gtk_widget_set_sensitive (GTK_WIDGET (private->tree_view), TRUE);    gdk_window_set_cursor (GTK_WIDGET (private->tree_view)->window, NULL);}void g_segy_ensemble_select_disable (GSEGYEnsembleSelect *self) {    GSEGYEnsembleSelectPrivate *private = G_SEGY_ENSEMBLE_SELECT_GET_PRIVATE (self);    private->block_selection = TRUE;    gtk_widget_set_sensitive (GTK_WIDGET (private->tree_view), FALSE);    gdk_window_set_cursor (GTK_WIDGET (private->tree_view)->window, private->watch_cursor);}static void g_segy_ensemble_select_ensemble_select_signal (GSEGYEnsembleSelect *self) {    GSEGYEnsembleSelectPrivate *private = G_SEGY_ENSEMBLE_SELECT_GET_PRIVATE (self);    g_signal_emit (self, G_SEGY_ENSEMBLE_SELECT_GET_CLASS (self)->ensemble_select_id, 0, private->list_selection);}static void g_segy_ensemble_select_get_selection (GSEGYEnsembleSelect *self) {    GSEGYEnsembleSelectPrivate *private = G_SEGY_ENSEMBLE_SELECT_GET_PRIVATE (self);    GtkTreeSelection* tree_selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (private->tree_view));    GList *tree_path_list = gtk_tree_selection_get_selected_rows (tree_selection, NULL);    GtkTreePath *tree_path = (GtkTreePath*)g_list_nth_data (tree_path_list, 0);    gint* tree_indices = gtk_tree_path_get_indices (tree_path);    private->list_selection = tree_indices[0];    g_list_free (tree_path_list);}static void g_segy_ensemble_select_set_selection (GSEGYEnsembleSelect *self) {    GSEGYEnsembleSelectPrivate *private = G_SEGY_ENSEMBLE_SELECT_GET_PRIVATE (self);    if (private->block_selection)        return;    GdkRectangle old_rect, new_rect;    gtk_tree_view_get_visible_rect  (GTK_TREE_VIEW (private->tree_view), &old_rect);    GtkTreeSelection* tree_selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (private->tree_view));    GtkTreePath *new_tree_path = gtk_tree_path_new_from_indices (private->list_selection, -1);    gtk_tree_selection_select_path (tree_selection, new_tree_path);    gtk_tree_view_scroll_to_cell (GTK_TREE_VIEW (private->tree_view), new_tree_path, NULL, FALSE, 0, 0);    gtk_tree_view_get_visible_rect  (GTK_TREE_VIEW (private->tree_view), &new_rect);    if (old_rect.y < new_rect.y)        gtk_tree_view_scroll_to_cell (GTK_TREE_VIEW (private->tree_view), new_tree_path, NULL, TRUE, 0, 0);    else if (old_rect.y > new_rect.y)        gtk_tree_view_scroll_to_cell (GTK_TREE_VIEW (private->tree_view), new_tree_path, NULL, TRUE, 1, 0);    gtk_tree_path_free (new_tree_path);    g_segy_ensemble_select_ensemble_select_signal (self);}static gboolean g_segy_ensemble_select_previous_ensemble (GSEGYEnsembleSelect *self) {    GSEGYEnsembleSelectPrivate *private = G_SEGY_ENSEMBLE_SELECT_GET_PRIVATE (self);    if (0 == private->list_selection || private->block_selection)        return FALSE;    private->list_selection = private->list_selection - 1;    g_segy_ensemble_select_set_selection (self);    return TRUE;}static void g_segy_ensemble_select_previous_ensemble_handler (GtkWidget *widget, gpointer data) {    g_segy_ensemble_select_previous_ensemble (G_SEGY_ENSEMBLE_SELECT (data));}static gboolean g_segy_ensemble_select_next_ensemble (GSEGYEnsembleSelect *self) {    GSEGYEnsembleSelectPrivate *private = G_SEGY_ENSEMBLE_SELECT_GET_PRIVATE (self);    if (private->list_selection == private->labels->len - 1 || private->block_selection)        return FALSE;    private->list_selection = private->list_selection + 1;    g_segy_ensemble_select_set_selection (self);    return TRUE;}static void g_segy_ensemble_select_next_ensemble_handler (GtkWidget *widget, gpointer data) {    g_segy_ensemble_select_next_ensemble (G_SEGY_ENSEMBLE_SELECT (data));}void g_segy_ensemble_select_next (GSEGYEnsembleSelect *self) {    g_segy_ensemble_select_next_ensemble (self);}void g_segy_ensemble_select_previous (GSEGYEnsembleSelect *self) {    g_segy_ensemble_select_previous_ensemble (self);}static gboolean g_segy_ensemble_select_animate (gpointer data) {    GSEGYEnsembleSelect *self = G_SEGY_ENSEMBLE_SELECT (data);    GSEGYEnsembleSelectPrivate *private = G_SEGY_ENSEMBLE_SELECT_GET_PRIVATE (self);    if (private->stop_animation) {        private->restart_animation = FALSE;        g_timer_stop (private->animation_timer);        gdk_threads_enter ();        gtk_widget_set_sensitive (private->stop_ensemble_button, FALSE);        gdk_threads_leave ();        private->animation_timeout_source = 0;        return FALSE;    }    if (private->restart_animation) {

⌨️ 快捷键说明

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