diff options
| -rw-r--r-- | .gitmodules | 3 | ||||
| -rw-r--r-- | CMakeLists.txt | 48 | ||||
| m--------- | deps/uber-graph | 0 | ||||
| -rw-r--r-- | shell/loadgraph-uber.c | 103 | 
4 files changed, 151 insertions, 3 deletions
diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 00000000..43026ff5 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "deps/uber-graph"] +	path = deps/uber-graph +	url = https://github.com/chergert/uber-graph.git diff --git a/CMakeLists.txt b/CMakeLists.txt index 04bc34c1..03aa30c7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -76,7 +76,7 @@ add_subdirectory(po)  include(FindPkgConfig)  if (HARDINFO_GTK3)  	message(STATUS "Building for GTK3 (experimental!)") -	pkg_check_modules(GTK REQUIRED gtk+-3.0>=3.0 cairo>=1.0 cairo-png>=1.0 glib-2.0>=2.10 gthread-2.0>=2.10 gmodule-export-2.0>=2.10) +	pkg_check_modules(GTK REQUIRED pangocairo>=1.0 gtk+-3.0>=3.0 cairo>=1.0 cairo-png>=1.0 glib-2.0>=2.10 gthread-2.0>=2.10 gmodule-export-2.0>=2.10)  	add_definitions(-DGTK_DISABLE_SINGLE_INCLUDES)  else()  	message(STATUS "Building for GTK2") @@ -93,6 +93,7 @@ include_directories(  	${CMAKE_SOURCE_DIR}  	${CMAKE_SOURCE_DIR}/includes  	${CMAKE_SOURCE_DIR}/includes/${HARDINFO_ARCH} +	${CMAKE_SOURCE_DIR}/deps/uber-graph/uber  	${CMAKE_BINARY_DIR}  	${GTK_INCLUDE_DIRS}  	${LIBSOUP_INCLUDE_DIRS} @@ -192,6 +193,23 @@ foreach (_module ${HARDINFO_MODULES})  	set_target_properties(${_module} PROPERTIES PREFIX "")  endforeach() +if (HARDINFO_GTK3) +add_library(uber-graph STATIC +	deps/uber-graph/uber/g-ring.c +	deps/uber-graph/uber/uber-frame-source.c +	deps/uber-graph/uber/uber-graph.c +	deps/uber-graph/uber/uber-heat-map.c +	deps/uber-graph/uber/uber-label.c +	deps/uber-graph/uber/uber-line-graph.c +	deps/uber-graph/uber/uber-range.c +	deps/uber-graph/uber/uber-scale.c +	deps/uber-graph/uber/uber-scatter.c +	deps/uber-graph/uber/uber-timeout-interval.c +	deps/uber-graph/uber/uber-window.c +) +endif() + +if (HARDINFO_GTK3)  add_executable(hardinfo  	hardinfo/binreloc.c  	hardinfo/expr.c @@ -201,20 +219,44 @@ add_executable(hardinfo  	hardinfo/vendor.c  	shell/callbacks.c  	shell/iconcache.c -	shell/loadgraph.c  	shell/menu.c  	shell/report.c  	shell/shell.c  	shell/stock.c  	shell/syncmanager.c +	shell/loadgraph-uber.c  ) -  target_link_libraries(hardinfo +	uber-graph  	${GTK_LIBRARIES}  	${LIBSOUP_LIBRARIES}  	m  	${ZLIB_LIBRARIES}  ) +else() +add_executable(hardinfo +	hardinfo/binreloc.c +	hardinfo/expr.c +        hardinfo/hardinfo.c +	hardinfo/socket.c +	hardinfo/util.c +	hardinfo/vendor.c +	shell/callbacks.c +	shell/iconcache.c +	shell/menu.c +	shell/report.c +	shell/shell.c +	shell/stock.c +	shell/syncmanager.c +	shell/loadgraph.c +) +target_link_libraries(hardinfo +	${GTK_LIBRARIES} +	${LIBSOUP_LIBRARIES} +	m +	${ZLIB_LIBRARIES} +) +endif()  configure_file(config.h.cmake ${CMAKE_BINARY_DIR}/config.h @ONLY)  configure_file(hardinfo.desktop.cmake ${CMAKE_BINARY_DIR}/hardinfo.desktop @ONLY) diff --git a/deps/uber-graph b/deps/uber-graph new file mode 160000 +Subproject d31c8014d8cc9f293dfecfcb4bd6a7bf4d61c0b diff --git a/shell/loadgraph-uber.c b/shell/loadgraph-uber.c new file mode 100644 index 00000000..d05fc7ee --- /dev/null +++ b/shell/loadgraph-uber.c @@ -0,0 +1,103 @@ +/* + * Christian Hergert's uber-graph (GPL3) + * wrapped in an interface compatible with + * Leandro A. F. Pereira's loadgraph (GPL2.1). + */ + +#include <string.h> +#include "loadgraph.h" +#include "uber.h" + +struct _LoadGraph { +    GtkWidget *uber_widget; +    gdouble cur_value; +    gint height; +}; + +gdouble +_sample_func (UberLineGraph *graph, +                 guint      line, +                 gpointer   user_data) +{ +    LoadGraph *lg = (LoadGraph *)user_data; +        return lg->cur_value; +} + +LoadGraph *load_graph_new(gint size) +{ +    LoadGraph *lg; +    GdkRGBA color; + +    lg = g_new0(LoadGraph, 1); + +    lg->height = (size+1) * 2; /* idk */ +    lg->cur_value = 0.0; +    lg->uber_widget = uber_line_graph_new(); + +    uber_line_graph_set_autoscale(UBER_LINE_GRAPH(lg->uber_widget), TRUE); +    GtkWidget *label = uber_label_new(); +    uber_label_set_text(UBER_LABEL(label), "BLAH!"); +    gdk_rgba_parse(&color, "#729fcf"); +    uber_line_graph_add_line(UBER_LINE_GRAPH(lg->uber_widget), &color, UBER_LABEL(label)); +    uber_line_graph_set_data_func(UBER_LINE_GRAPH(lg->uber_widget), +                (UberLineGraphFunc)_sample_func, (gpointer *)lg, NULL); + +    return lg; +} + +void load_graph_set_data_suffix(LoadGraph * lg, gchar * suffix) +{ + +} + +gchar *load_graph_get_data_suffix(LoadGraph * lg) +{ +    return strdup(""); +} + +GtkWidget *load_graph_get_framed(LoadGraph * lg) +{ +    if (lg != NULL) +        return lg->uber_widget; +    return NULL; +} + +void load_graph_clear(LoadGraph * lg) +{ + +} + +void load_graph_set_color(LoadGraph * lg, LoadGraphColor color) +{ + +} + +void load_graph_destroy(LoadGraph * lg) +{ +    if (lg != NULL) { +        g_object_unref(lg->uber_widget); +        g_free(lg); +    } +} + +static gboolean _expose(GtkWidget * widget, GdkEventExpose * event, gpointer user_data) +{ +    return TRUE; +} + +void load_graph_configure_expose(LoadGraph * lg) +{ + +} + +void load_graph_update(LoadGraph * lg, gdouble value) +{ +    if (lg != NULL) +        lg->cur_value = value; +} + +gint load_graph_get_height(LoadGraph *lg) { +    if (lg != NULL) +        return lg->height; +    return 0; +}  | 
