Permalink
Browse files

gtk3: Christian Hergert's uber-graph replacing loadgraph

Signed-off-by: Burt P <pburt0@gmail.com>
  • Loading branch information...
bp0 authored and lpereira committed Jul 26, 2017
1 parent d58276a commit 650f07f6d0e01bed154c34109b45e736663a3d93
Showing with 152 additions and 3 deletions.
  1. +3 −0 .gitmodules
  2. +45 −3 CMakeLists.txt
  3. +1 −0 deps/uber-graph
  4. +103 −0 shell/loadgraph-uber.c
View
@@ -0,0 +1,3 @@
[submodule "deps/uber-graph"]
path = deps/uber-graph
url = https://github.com/chergert/uber-graph.git
View
@@ -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)
Submodule uber-graph added at d31c80
View
@@ -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;
}

0 comments on commit 650f07f

Please sign in to comment.