summaryrefslogtreecommitdiff
path: root/gtkcalls_unix.go
diff options
context:
space:
mode:
authorPietro Gagliardi <[email protected]>2014-06-02 13:01:36 -0400
committerPietro Gagliardi <[email protected]>2014-06-02 13:01:36 -0400
commite28dff429dfa622e89c2a1460fba07b409dad611 (patch)
tree73e07f99ddaedc92f4f213b3606582ef9b6a7f64 /gtkcalls_unix.go
parent09a5a859a00da7124076e18a366c3c25d523dc31 (diff)
Made the GTK+ ProgressBar arbitrary resize a program-global style.
Diffstat (limited to 'gtkcalls_unix.go')
-rw-r--r--gtkcalls_unix.go26
1 files changed, 13 insertions, 13 deletions
diff --git a/gtkcalls_unix.go b/gtkcalls_unix.go
index b6da4d6..21b46b9 100644
--- a/gtkcalls_unix.go
+++ b/gtkcalls_unix.go
@@ -12,11 +12,10 @@ import (
// #include "gtk_unix.h"
// /* TODO this doesn't need to be in C; it is because an earlier version did it wrong and depended on a function (g_object_set()) that took ..., which cgo doesn't like... but is it safe to embed \0 in a Go string? */
-// static inline char *gtkProgressBarAllowArbitraryResize(GtkWidget *pbar)
+// static inline GError *gtkProgressBarAllowArbitraryResize()
// {
// /* min-horizontal-bar-width is a style property; we do it through CSS */
// /* thanks tristan in irc.gimp.net/#gtk+ */
-// /* TODO find out how to make it an application default */
// static gchar style[] =
// "* {\n"
// " -GtkProgressBar-min-horizontal-bar-width: 1;\n"
@@ -26,8 +25,10 @@ import (
//
// provider = gtk_css_provider_new();
// if (gtk_css_provider_load_from_data(provider, style, -1, &err) == FALSE)
-// return (char *) g_strdup(err->message);
-// gtk_style_context_add_provider(gtk_widget_get_style_context(pbar),
+// return err;
+// /* GDK (at least as far back as GTK+ 3.4, but officially documented as of 3.10) merges all screens into one big one, so we don't need to worry about multimonitor */
+// /* thanks to baedert and mclasen in irc.gimp.net/#gtk+ */
+// gtk_style_context_add_provider_for_screen(gdk_screen_get_default(),
// (GtkStyleProvider *) provider, GTK_STYLE_PROVIDER_PRIORITY_USER);
// return NULL;
// }
@@ -40,7 +41,13 @@ func gtk_init() error {
// TODO allow GTK+ standard command-line argument processing?
result := C.gtk_init_with_args(nil, nil, nil, nil, nil, &err)
if result == C.FALSE {
- return fmt.Errorf("%s", fromgstr(err.message))
+ return fmt.Errorf("error actually initilaizing GTK+: %s", fromgstr(err.message))
+ }
+ // otherwise progress bars can't be resized smaller than some predetermined size
+ err = C.gtkProgressBarAllowArbitraryResize()
+ if err != nil {
+ defer C.g_free(C.gpointer(unsafe.Pointer(err)))
+ return fmt.Errorf("error allowing ProgressBar to be arbitrarily resized: %s", fromgstr(err.message))
}
return nil
}
@@ -255,14 +262,7 @@ func gtk_widget_get_preferred_size(widget *C.GtkWidget) (minWidth int, minHeight
}
func gtk_progress_bar_new() *C.GtkWidget {
- p := C.gtk_progress_bar_new()
- // otherwise the progress bar can't be resized smaller than some predetermined size
- err := C.gtkProgressBarAllowArbitraryResize(p)
- if err != nil {
- defer C.g_free(C.gpointer(unsafe.Pointer(err)))
- panic(fmt.Errorf("error allowing ProgressBar to be arbitrarily resized: %s", C.GoString(err)))
- }
- return p
+ return C.gtk_progress_bar_new()
}
func gtk_progress_bar_set_fraction(w *C.GtkWidget, percent int) {