#include <gtk/gtk.h>
#include <glib/gstdio.h>
+#ifdef MAC_INTEGRATION
+#include <gtkosxapplication.h>
+#endif
+
#include <grits.h>
#include "aweather-gui.h"
}
}
+static void xdg_open(GtkLinkButton *button, const gchar *link, gpointer user_data)
+{
+ gchar *argv[] = {"xdg-open", (gchar*)link, NULL};
+ g_spawn_async(NULL, argv, NULL, G_SPAWN_SEARCH_PATH, NULL, NULL, NULL, NULL);
+}
+
static void on_log_level_changed(GtkSpinButton *spinner, AWeatherGui *self)
{
g_message("main: log_level_changed");
gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(object), enabled);
}
+static void setup_mac(AWeatherGui *gui)
+{
+#ifdef MAC_INTEGRATION
+ GtkWidget *menu = aweather_gui_get_widget(gui, "main_menu");
+ GtkOSXApplication *app = g_object_new(GTK_TYPE_OSX_APPLICATION, NULL);
+ gtk_widget_hide(menu);
+ gtk_osxapplication_set_menu_bar(app, GTK_MENU_SHELL(menu));
+ gtk_osxapplication_set_use_quartz_accelerators(app, TRUE);
+ gtk_osxapplication_ready(app);
+ //gtk_osxapplication_sync_menubar(app)
+#endif
+}
+
/********
* Main *
********/
return -1;
}
+ /* Use external handler for link buttons */
+ gtk_link_button_set_uri_hook(xdg_open, NULL, NULL);
+
/* Setup debug level for aweather_gui_new */
g_log_set_handler(NULL, G_LOG_LEVEL_MASK, log_func, NULL);
log_levels = int2log(opt_debug >= 0 ? opt_debug : debug);
/* Done with init, show gui */
gtk_widget_show_all(GTK_WIDGET(gui));
set_toggle_action(gui, "fullscreen", fullscreen); // Resest widget hiding
+ setup_mac(gui); // done after show_all
gtk_main();
gdk_threads_leave();
gdk_display_close(gdk_display_get_default());