tmp
authoryu.dongliang <18588496441@163.com>
Sat, 15 Apr 2023 07:21:33 +0000 (15:21 +0800)
committeryu.dongliang <18588496441@163.com>
Sat, 15 Apr 2023 07:21:33 +0000 (15:21 +0800)
main.c
simp.glade
simp.h

diff --git a/main.c b/main.c
index c06b6ad1ac8fd001cacf1ba175c8b50b4eee8650..41eeecf3fda7644509accb6d80a078c4b2a00869 100644 (file)
--- a/main.c
+++ b/main.c
@@ -1,21 +1,12 @@
 #include <gtk/gtk.h>
-#include <assert.h>
+#include "simp.h"
 
-void chess_file_new(GtkMenuButton* self, gpointer user_data)
-{
-       printf("%s(),%d\n", __func__, __LINE__);
-
-       GtkBuilder  *builder;
-       GtkNotebook *code_notebook;
-       GtkWidget   *code_page;
+GtkWidget*  gl_area = NULL;
 
-       builder = GTK_BUILDER(user_data);
-}
-
-void chess_file_open(GtkMenuButton* self, gpointer user_data)
+void simp_file_add(GtkMenuButton* self, gpointer user_data)
 {
        printf("%s(),%d\n", __func__, __LINE__);
-
+#if 0
        GtkBuilder  *builder;
        GtkWindow   *window;
        GtkWidget   *dialog;
@@ -25,7 +16,7 @@ void chess_file_open(GtkMenuButton* self, gpointer user_data)
 
        GtkFileChooserAction action = GTK_FILE_CHOOSER_ACTION_OPEN;
 
-       dialog = gtk_file_chooser_dialog_new ("Open File",
+       dialog = gtk_file_chooser_dialog_new ("add source",
                        window,
                        action,
                        "_Cancel",
@@ -37,41 +28,10 @@ void chess_file_open(GtkMenuButton* self, gpointer user_data)
        gtk_widget_show(dialog);
 
        g_signal_connect(dialog, "response", G_CALLBACK(on_open_response), NULL);
+#endif
 }
 
-void chess_file_save(GtkMenuButton* self, gpointer user_data)
-{
-       printf("%s(),%d\n", __func__, __LINE__);
-}
-
-void chess_file_save_as(GtkMenuButton* self, gpointer user_data)
-{
-       printf("%s(),%d\n", __func__, __LINE__);
-
-       GtkBuilder  *builder;
-       GtkWindow   *window;
-       GtkWidget   *dialog;
-
-       builder = GTK_BUILDER(user_data);
-       window  = GTK_WINDOW(gtk_builder_get_object(builder, "main_window"));
-
-       GtkFileChooserAction action = GTK_FILE_CHOOSER_ACTION_SAVE;
-
-       dialog = gtk_file_chooser_dialog_new ("Save File",
-                       window,
-                       action,
-                       "_Cancel",
-                       GTK_RESPONSE_CANCEL,
-                       "_Save",
-                       GTK_RESPONSE_ACCEPT,
-                       NULL);
-
-       gtk_widget_show(dialog);
-
-       g_signal_connect(dialog, "response", G_CALLBACK(on_save_response), NULL);
-}
-
-void chess_edit_reset(GtkMenuButton* self, gpointer user_data)
+void simp_edit_play(GtkMenuButton* self, gpointer user_data)
 {
        printf("%s(),%d\n", __func__, __LINE__);
 
@@ -110,12 +70,12 @@ static gboolean render(GtkGLArea *area, GdkGLContext *context)
        if (gtk_gl_area_get_error (area) != NULL)
                return FALSE;
 
-       glViewport(0, 0, 512, 512);
+       glViewport(0, 0, 1920, 1080);
 
        glClearColor (1.0, 0.0, 0.0, 1.0);
        glClear (GL_COLOR_BUFFER_BIT);
 
-//     chess_gl_draw(gl);
+       // draw
 
        glFlush ();
 
@@ -128,68 +88,75 @@ static gboolean button_release_event (GtkWidget* self, GdkEventButton* event, gp
        return TRUE;
 }
 
+static gboolean simp_record(GtkWidget* self, GdkEventButton* event, gpointer user_data)
+{
+       printf("%s(),%d\n", __func__, __LINE__);
+       return TRUE;
+}
+
+static gboolean simp_pause(GtkWidget* self, GdkEventButton* event, gpointer user_data)
+{
+       printf("%s(),%d\n", __func__, __LINE__);
+       return TRUE;
+}
+
+static gboolean simp_stop(GtkWidget* self, GdkEventButton* event, gpointer user_data)
+{
+       printf("%s(),%d\n", __func__, __LINE__);
+       return TRUE;
+}
 
 int main(int argc, char *argv[])
 {
        printf("%s(),%d\n", __func__, __LINE__);
 
        GtkBuilder *builder;
-       GObject *window;
-
-       GObject *menu_file_quit;
-       GObject *menu_file_new;
-       GObject *menu_file_open;
-       GObject *menu_file_save;
-       GObject *menu_file_save_as;
-       GObject *menu_edit_back;
-       GObject *menu_edit_next;
-       GObject *menu_edit_mode;
-       GObject *menu_edit_reset;
-       GError  *error = NULL;
+       GObject    *window;
+
+       GObject    *menu_file_quit;
+       GObject    *menu_file_add;
+
+       GObject    *button_record;
+       GObject    *button_pause;
+       GObject    *button_stop;
+
+       GError     *error = NULL;
 
        gtk_init (&argc, &argv);
-#if 1
-       builder = gtk_builder_new (); 
-       if (gtk_builder_add_from_file (builder, "chess.glade", &error) == 0)
+
+       builder = gtk_builder_new();
+       if (gtk_builder_add_from_file (builder, "simp.glade", &error) == 0)
        {   
                g_printerr ("Error loading file: %s\n", error->message);
                g_clear_error (&error);
                return 1;
        }
-#endif
-       window = gtk_builder_get_object (builder, "main_window");
-       g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL);
-
-#if 1
-       menu_file_quit    = gtk_builder_get_object (builder, "menu_file_quit");
-       menu_file_new     = gtk_builder_get_object (builder, "menu_file_new");
-       menu_file_open    = gtk_builder_get_object (builder, "menu_file_open");
-       menu_file_save    = gtk_builder_get_object (builder, "menu_file_save");
-       menu_file_save_as = gtk_builder_get_object (builder, "menu_file_save_as");
-
-       menu_edit_back    = gtk_builder_get_object (builder, "menu_edit_back");
-       menu_edit_next    = gtk_builder_get_object (builder, "menu_edit_next");
-       menu_edit_reset   = gtk_builder_get_object (builder, "menu_edit_reset");
-
-       g_signal_connect(menu_file_quit,    "activate", G_CALLBACK(gtk_main_quit),        NULL);
-       g_signal_connect(menu_file_new,     "activate", G_CALLBACK(chess_file_new),     builder);
-       g_signal_connect(menu_file_open,    "activate", G_CALLBACK(chess_file_open),    builder);
-       g_signal_connect(menu_file_save,    "activate", G_CALLBACK(chess_file_save),    builder);
-       g_signal_connect(menu_file_save_as, "activate", G_CALLBACK(chess_file_save_as), builder);
-
-       g_signal_connect(menu_edit_back,    "activate", G_CALLBACK(chess_edit_back),    builder);
-       g_signal_connect(menu_edit_next,    "activate", G_CALLBACK(chess_edit_next),    builder);
-       g_signal_connect(menu_edit_reset,   "activate", G_CALLBACK(chess_edit_reset),   builder);
-       g_signal_connect(menu_edit_mode,    "activate", G_CALLBACK(chess_edit_mode),    builder);
 
-#endif
-       gl_area = GTK_WIDGET(gtk_builder_get_object(builder, "gl_area"));
+       window         = gtk_builder_get_object (builder, "main_window");
+
+       menu_file_quit = gtk_builder_get_object (builder, "menu_file_quit");
+       menu_file_add  = gtk_builder_get_object (builder, "menu_file_add");
+
+       button_record  = gtk_builder_get_object (builder, "button_record");
+       button_pause   = gtk_builder_get_object (builder, "button_pause");
+       button_stop    = gtk_builder_get_object (builder, "button_stop");
+
+       gl_area        = GTK_WIDGET(gtk_builder_get_object(builder, "gl_area"));
+
+       g_signal_connect(window,         "destroy",   G_CALLBACK(gtk_main_quit), NULL);
+
+       g_signal_connect(menu_file_quit, "activate",  G_CALLBACK(gtk_main_quit), NULL);
+       g_signal_connect(menu_file_add,  "activate",  G_CALLBACK(simp_file_add), builder);
+
+       g_signal_connect(button_record,  "activate",  G_CALLBACK(simp_record),   builder);
+       g_signal_connect(button_pause,   "activate",  G_CALLBACK(simp_pause),    builder);
+       g_signal_connect(button_stop,    "activate",  G_CALLBACK(simp_stop),     builder);
 
-       g_signal_connect (gl_area, "resize", G_CALLBACK (resize), NULL);
-       g_signal_connect (gl_area, "unrealize", G_CALLBACK (unrealize), NULL);
-       g_signal_connect (gl_area, "render", G_CALLBACK (render), NULL);
+       g_signal_connect(gl_area,        "resize",    G_CALLBACK(resize),        NULL);
+       g_signal_connect(gl_area,        "unrealize", G_CALLBACK(unrealize),     NULL);
+       g_signal_connect(gl_area,        "render",    G_CALLBACK(render),        NULL);
 
-       g_signal_connect (window, "button-release-event", G_CALLBACK (button_release_event), NULL);
+       g_signal_connect(window, "button-release-event", G_CALLBACK(button_release_event), NULL);
 
        gtk_widget_show_all(GTK_WIDGET(window));
 
index 588fde08cb260a991f2da603adc072340d704fb4..e8130c4e83f69b27ace705d854094531584a585d 100644 (file)
@@ -7,8 +7,8 @@
     <property name="can_focus">False</property>
     <property name="title" translatable="yes">国际象棋</property>
     <property name="resizable">False</property>
-    <property name="default_width">640</property>
-    <property name="default_height">544</property>
+    <property name="default_width">1280</property>
+    <property name="default_height">720</property>
     <child>
       <placeholder/>
     </child>
@@ -71,7 +71,7 @@
                         <property name="can_focus">False</property>
                         <child>
                           <object class="GtkImageMenuItem" id="menu_edit_play">
-                            <property name="label">上一步(B)</property>
+                            <property name="label">播放(P)</property>
                             <property name="visible">True</property>
                             <property name="can_focus">False</property>
                             <property name="use_underline">True</property>
diff --git a/simp.h b/simp.h
index bf7c56db8ad5cd5a4a1772be64dc1aac0041e71d..ca7307987a3ce3d76e099ab9cfa47780fd8d5ce5 100644 (file)
--- a/simp.h
+++ b/simp.h
 #include "libavfilter/buffersink.h"
 #include "libavutil/audio_fifo.h"
 
+#define  GL_GLEXT_PROTOTYPES
+#include <GL/gl.h>
+#include <GL/glext.h>
+
 typedef struct simp_avio_s       simp_avio_t;
 typedef struct simp_avio_ops_s   simp_avio_ops_t;