コード例 #1
0
static void
break_window_postpone_cb (GtkWidget *window,
                          DrWright  *dr)
{
    gint elapsed_time;

    gtk_widget_destroy (dr->break_window);

    dr->state = STATE_RUNNING;
    dr->break_window = NULL;

    elapsed_time = drw_timer_elapsed (dr->timer);

    if (elapsed_time + dr->save_last_time >= dr->type_time) {
        /* Typing time has expired, but break was postponed.
         * We'll warn again in (elapsed * sqrt (typing_time))^2 */
        gfloat postpone_time = (((float) elapsed_time) / dr->break_time)
                               * sqrt (dr->type_time);
        postpone_time *= postpone_time;
        dr->save_last_time = dr->type_time - MAX (dr->warn_time, (gint) postpone_time);
    }

    drw_timer_start (dr->timer);
    maybe_change_state (dr);
    update_status (dr);
#ifdef HAVE_APP_INDICATOR
    update_app_indicator (dr);
#else
    update_icon (dr);
#endif /* HAVE_APP_INDICATOR */
}
コード例 #2
0
static void
popup_break_cb (GtkAction *action, DrWright *dr)
{
    if (dr->enabled) {
        dr->state = STATE_BREAK_SETUP;
        maybe_change_state (dr);
    }
}
コード例 #3
0
ファイル: drwright.c プロジェクト: GNOME/drwright
static void
break_window_done_cb (GtkWidget *window,
		      DrWright  *dr)
{
	gtk_widget_destroy (dr->break_window);

	dr->state = STATE_BREAK_DONE_SETUP;
	dr->break_window = NULL;

	maybe_change_state (dr);
}
コード例 #4
0
static void
popup_break_cb (gpointer   callback_data,
		guint      action,
		GtkWidget *widget)
{
	DrWright *dr = callback_data;

	if (dr->enabled) {
		dr->state = STATE_BREAK_SETUP;
		maybe_change_state (dr);
	}
}
コード例 #5
0
ファイル: drwright.c プロジェクト: GNOME/drwright
static void
notification_action_cb (NotifyNotification *notification,
                        const char *action,
                        DrWright *dr)
{
	GAppInfo *app_info;
	GdkAppLaunchContext *launch_context;

	g_assert (action != NULL);

	if (g_strcmp0 (action, "take-break") == 0) {
		if (dr->enabled) {
			dr->state = STATE_BREAK_SETUP;
			maybe_change_state (dr);
		}
	}
	else if (g_strcmp0 (action, "settings") == 0) {
		GError *error = NULL;

		launch_context = gdk_display_get_app_launch_context (gdk_display_get_default ());

		app_info = g_app_info_create_from_commandline (BINDIR "/gnome-control-center typing-break",
		                                               NULL,
		                                               G_APP_INFO_CREATE_SUPPORTS_STARTUP_NOTIFICATION,
		                                               &error);
		if (error) {
			g_warning ("%s", error->message);
			goto out;
		}

		g_app_info_launch (app_info, NULL, G_APP_LAUNCH_CONTEXT (launch_context), &error);
		if (error) {
			g_warning ("%s", error->message);
		}
out:
		g_clear_error (&error);
		g_object_unref (launch_context);
	}
	else {
		g_warning ("Unknown action: %s", action);
	}
}
コード例 #6
0
ファイル: drwright.c プロジェクト: GNOME/drwright
static void
settings_change_cb (GSettings  *settings,
                    const char *key,
                    DrWright   *dr)
{
        dr->state = STATE_START;

        if (!key || key == I_("type-time")) {
                dr->type_time = g_settings_get_int (settings, "type-time");
                dr->warn_time = MIN (dr->type_time / 10, WARN_TIME_MAX);
	}
	if (!key || key == I_("break-time")) {
                dr->break_time = g_settings_get_int (settings, "break-time");
	}
	if (!key || key == I_("enabled")) {
                dr->enabled = g_settings_get_boolean (settings, "enabled");
	}

	maybe_change_state (dr);
}
コード例 #7
0
static void
mateconf_notify_cb (MateConfClient *client,
                    guint        cnxn_id,
                    MateConfEntry  *entry,
                    gpointer     user_data)
{
    DrWright  *dr = user_data;
    GtkWidget *item;

    if (!strcmp (entry->key, MATECONF_PATH "/type_time")) {
        if (entry->value->type == MATECONF_VALUE_INT) {
            dr->type_time = 60 * mateconf_value_get_int (entry->value);
            dr->warn_time = MIN (dr->type_time / 10, 5*60);

            dr->state = STATE_START;
        }
    }
    else if (!strcmp (entry->key, MATECONF_PATH "/break_time")) {
        if (entry->value->type == MATECONF_VALUE_INT) {
            dr->break_time = 60 * mateconf_value_get_int (entry->value);
            dr->state = STATE_START;
        }
    }
    else if (!strcmp (entry->key, MATECONF_PATH "/enabled")) {
        if (entry->value->type == MATECONF_VALUE_BOOL) {
            dr->enabled = mateconf_value_get_bool (entry->value);
            dr->state = STATE_START;

            item = gtk_ui_manager_get_widget (dr->ui_manager,
                                              "/Pop/TakeABreak");
            gtk_widget_set_sensitive (item, dr->enabled);

            update_status (dr);
        }
    }

    maybe_change_state (dr);
}
コード例 #8
0
static void
gconf_notify_cb (GConfClient *client,
		 guint        cnxn_id,
		 GConfEntry  *entry,
		 gpointer     user_data)
{
	DrWright  *dr = user_data;
	GtkWidget *item;

	if (!strcmp (entry->key, GCONF_PATH "/type_time")) {
		if (entry->value->type == GCONF_VALUE_INT) {
			dr->type_time = 60 * gconf_value_get_int (entry->value);
			dr->warn_time = MIN (dr->type_time / 10, 5*60);

			dr->state = STATE_START;
		}
	}
	else if (!strcmp (entry->key, GCONF_PATH "/break_time")) {
		if (entry->value->type == GCONF_VALUE_INT) {
			dr->break_time = 60 * gconf_value_get_int (entry->value);
			dr->state = STATE_START;
		}
	}
	else if (!strcmp (entry->key, GCONF_PATH "/enabled")) {
		if (entry->value->type == GCONF_VALUE_BOOL) {
			dr->enabled = gconf_value_get_bool (entry->value);
			dr->state = STATE_START;

			item = gtk_item_factory_get_widget_by_action (dr->popup_factory,
								      POPUP_ITEM_BREAK);
			gtk_widget_set_sensitive (item, dr->enabled);

			update_tooltip (dr);
		}
	}

	maybe_change_state (dr);
}