Beispiel #1
0
static void
on_toggled (GtkToggleButton *button, gpointer user_data)
{
  gboolean state;

  state = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button));

  gtk_button_set_label (GTK_BUTTON (button), state ? "Go Offline" : "Go Online");

  emit_notify (state);
}
static void
state_changed (NMClient         *client,
               const GParamSpec *pspec,
               gpointer          data)
{
  if (sw_is_online()) {
    /* NM is notifying us too early - workaround that */
    g_timeout_add (1500, (GSourceFunc)we_are_online, NULL);
  } else {
    emit_notify (FALSE); /* sw_is_online ()); */
  }
}
static void
got_state_cb (DBusGProxy     *proxy,
              DBusGProxyCall *call,
              void           *user_data)
{
  char *state = NULL;
  GError *error = NULL;

  if (!dbus_g_proxy_end_call (proxy, call, &error,
			      G_TYPE_STRING, &state,
			      G_TYPE_INVALID)) {
    g_printerr ("Cannot get current online state: %s", error->message);
    g_error_free (error);
    return;
  }

  current_state = (g_strcmp0 (state, "online") == 0);
  emit_notify (current_state);
  g_free (state);
}
static void
state_changed (DBusGProxy *proxy, const char *new_state)
{
  current_state = (g_strcmp0 (new_state, "online") == 0);
  emit_notify (current_state);
}
static gboolean
we_are_online (gpointer user_data)
{
  emit_notify (sw_is_online ());
  return FALSE;
}