+/*
+ mtetherd
+ (c) 2010 Gregor Riepl <onitake@gmail.com>
+
+ Tethering utility for Maemo
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <pwd.h>
+#include <sys/types.h>
+#include <gtk/gtk.h>
+#include <hildon/hildon.h>
+
+#include "status.h"
+
+#define MTETHERD_STATUS_PLUGIN_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE(obj, TYPE_MTETHERD_STATUS_PLUGIN, MTetherDStatusPluginPrivate))
+
+struct _MTetherDStatusPluginPrivate {
+ GtkWidget *button;
+ gboolean neton;
+};
+
+HD_DEFINE_PLUGIN_MODULE(MTetherDStatusPlugin, mtetherd_status_plugin, HD_TYPE_STATUS_MENU_ITEM);
+
+static void mtetherd_status_plugin_class_finalize(MTetherDStatusPluginClass *klass) { }
+
+static void mtetherd_status_plugin_class_init(MTetherDStatusPluginClass *klass) {
+ g_type_class_add_private(klass, sizeof(MTetherDStatusPluginPrivate));
+}
+
+static void set_button_text(GtkWidget *button, gboolean enabled) {
+ if (enabled) {
+ gtk_button_set_label(GTK_BUTTON(button), "Disable USB Networking");
+ } else {
+ gtk_button_set_label(GTK_BUTTON(button), "Enable USB Networking");
+ }
+}
+
+static void enable_usb_net_clicked(GtkWidget *button, gpointer user) {
+ MTetherDStatusPlugin *plugin = MTETHERD_STATUS_PLUGIN(user);
+
+ if (button == plugin->priv->button) {
+ plugin->priv->neton = !plugin->priv->neton;
+ set_button_text(plugin->priv->button, plugin->priv->neton);
+ if (plugin->priv->neton) {
+ // enable
+ } else {
+ // disable
+ }
+ }
+}
+
+static void mtetherd_status_plugin_init(MTetherDStatusPlugin *plugin) {
+ plugin->priv = MTETHERD_STATUS_PLUGIN_GET_PRIVATE(plugin);
+
+ plugin->priv->neton = FALSE;
+ plugin->priv->button = gtk_button_new();
+ set_button_text(plugin->priv->button, plugin->priv->neton);
+ g_signal_connect(plugin->priv->button, "clicked", G_CALLBACK(enable_usb_net_clicked), plugin);
+ gtk_container_add(GTK_CONTAINER(plugin), plugin->priv->button);
+ gtk_widget_show_all(plugin->priv->button);
+ gtk_widget_show(GTK_WIDGET(plugin));
+}
+