Create basic GObject structure for GraphView
This commit is contained in:
parent
850ae7db43
commit
7323fd15e8
@ -1,18 +1,48 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of GtkGraphView.
|
||||||
|
*
|
||||||
|
* Foobar is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License version 2 as
|
||||||
|
* published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* GtkGraphView 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 details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with GtkGraphView. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
#include <gtk-graph-view.h>
|
#include <gtk-graph-view.h>
|
||||||
|
|
||||||
|
static gboolean main_window_delete_event(GtkWidget *window, gpointer user)
|
||||||
|
{
|
||||||
|
(void)user;
|
||||||
|
|
||||||
|
gtk_widget_destroy(window);
|
||||||
|
gtk_main_quit();
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
GtkWidget *main_window;
|
GtkWidget *main_window;
|
||||||
|
GtkWidget *graph_view;
|
||||||
printf("Hello World!\n");
|
|
||||||
|
|
||||||
gtk_init(&argc, &argv);
|
gtk_init(&argc, &argv);
|
||||||
|
|
||||||
main_window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
|
main_window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
|
||||||
gtk_widget_show(main_window);
|
gtk_window_set_default_size(GTK_WINDOW(main_window), 800, 800);
|
||||||
|
g_signal_connect(main_window, "delete-event", G_CALLBACK(main_window_delete_event), NULL);
|
||||||
|
|
||||||
|
graph_view = gtk_graph_view_new();
|
||||||
|
gtk_container_add(GTK_CONTAINER(main_window), graph_view);
|
||||||
|
|
||||||
|
gtk_widget_show_all(main_window);
|
||||||
gtk_main();
|
gtk_main();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -4,12 +4,14 @@ project(gtkgraphview LANGUAGES C)
|
|||||||
find_package(PkgConfig REQUIRED)
|
find_package(PkgConfig REQUIRED)
|
||||||
pkg_search_module(GLIB REQUIRED glib-2.0)
|
pkg_search_module(GLIB REQUIRED glib-2.0)
|
||||||
pkg_check_modules(GTK3 REQUIRED gtk+-3.0)
|
pkg_check_modules(GTK3 REQUIRED gtk+-3.0)
|
||||||
|
pkg_check_modules(EPOXY REQUIRED epoxy)
|
||||||
|
|
||||||
add_compile_options(-Wall -Wextra -Wold-style-declaration -Wuninitialized -Wmaybe-uninitialized -Wunused-parameter)
|
add_compile_options(-Wall -Wextra -Wold-style-declaration -Wuninitialized -Wmaybe-uninitialized -Wunused-parameter)
|
||||||
aux_source_directory("src" SRC_DIR)
|
aux_source_directory("src" SRC_DIR)
|
||||||
|
|
||||||
add_library(${PROJECT_NAME} SHARED ${SRC_DIR})
|
add_library(${PROJECT_NAME} SHARED ${SRC_DIR})
|
||||||
target_include_directories(${PROJECT_NAME} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include)
|
target_include_directories(${PROJECT_NAME} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include)
|
||||||
target_link_libraries(${PROJECT_NAME} PUBLIC ${GLIB_LDFLAGS} ${GTK3_LDFLAGS})
|
target_include_directories(${PROJECT_NAME} PRIVATE ${EPOXY_INCLUDE_DIRS})
|
||||||
target_link_directories(${PROJECT_NAME} PUBLIC ${GLIB_LINK_DIRS} ${GTK3_LINK_DIRS})
|
target_link_libraries(${PROJECT_NAME} PUBLIC ${GLIB_LDFLAGS} ${GTK3_LDFLAGS} ${EPOXY_LDFLAGS})
|
||||||
|
target_link_directories(${PROJECT_NAME} PUBLIC ${GLIB_LINK_DIRS} ${GTK3_LINK_DIRS} ${EPOXY_LINK_DIRS})
|
||||||
target_include_directories(${PROJECT_NAME} PUBLIC ${GLIB_INCLUDE_DIRS} ${GTK3_INCLUDE_DIRS})
|
target_include_directories(${PROJECT_NAME} PUBLIC ${GLIB_INCLUDE_DIRS} ${GTK3_INCLUDE_DIRS})
|
||||||
|
@ -0,0 +1,49 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of GtkGraphView.
|
||||||
|
*
|
||||||
|
* Foobar is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License version 2 as
|
||||||
|
* published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* GtkGraphView 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 details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with GtkGraphView. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file gtk-graph-view.h
|
||||||
|
* @brief header file for the GtkGraphView Widget
|
||||||
|
* @author Mario Hüttel <mario.huettel@gmx.net>
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @addtogroup GtkGraphView
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __GTK_GRAPH_VIEW_H__
|
||||||
|
#define __GTK_GRAPH_VIEW_H__
|
||||||
|
|
||||||
|
#include <gtk/gtk.h>
|
||||||
|
|
||||||
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
|
#define GTK_TYPE_GRAPH_VIEW (gtk_graph_view_get_type())
|
||||||
|
|
||||||
|
G_DECLARE_FINAL_TYPE(GtkGraphView, gtk_graph_view, GTK, GRAPH_VIEW, GtkGLArea)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Instanciate new GtkGraphView object
|
||||||
|
* @return created object
|
||||||
|
*/
|
||||||
|
GtkWidget *gtk_graph_view_new();
|
||||||
|
|
||||||
|
G_END_DECLS
|
||||||
|
|
||||||
|
#endif /* __GTK_GRAPH_VIEW_H__ */
|
||||||
|
|
||||||
|
/** @} */
|
@ -1,6 +1,56 @@
|
|||||||
#include <gtk-graph-view.h>
|
/*
|
||||||
|
* This file is part of GtkGraphView.
|
||||||
|
*
|
||||||
|
* Foobar is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License version 2 as
|
||||||
|
* published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* GtkGraphView 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 details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with GtkGraphView. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
int test()
|
#include <gtk-graph-view.h>
|
||||||
|
#include <epoxy/gl.h>
|
||||||
|
|
||||||
|
struct _GtkGraphView {
|
||||||
|
GtkGLArea parent;
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
int i; /**< @note This is just a dummy. Remove! */
|
||||||
|
} GtkGraphViewPrivate;
|
||||||
|
|
||||||
|
G_DEFINE_TYPE_WITH_PRIVATE(GtkGraphView, gtk_graph_view, GTK_TYPE_GL_AREA)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Init class structure of GtkGraphView
|
||||||
|
* @param klass Class structure
|
||||||
|
*/
|
||||||
|
static void gtk_graph_view_class_init(GtkGraphViewClass *klass)
|
||||||
{
|
{
|
||||||
return 1;
|
(void)klass;
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Init a new GtkGraphView GObject
|
||||||
|
* @param obj Object to initialize
|
||||||
|
*/
|
||||||
|
static void gtk_graph_view_init(GtkGraphView *obj)
|
||||||
|
{
|
||||||
|
GtkGraphViewPrivate *priv;
|
||||||
|
|
||||||
|
priv = gtk_graph_view_get_instance_private(obj);
|
||||||
|
priv->i = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
GtkWidget *gtk_graph_view_new()
|
||||||
|
{
|
||||||
|
return gtk_widget_new(GTK_TYPE_GRAPH_VIEW, NULL);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user