Пример #1
0
static void update_check_result_cb(SoupSession *session,
    SoupMessage *msg, gpointer user_data)
{
    gint type = GPOINTER_TO_INT(user_data);

    /* Checking whether we did get a valid (200) result */
    if (msg->status_code == 200)
    {
        const gchar *remote_version = msg->response_body->data;
        if (version_compare(remote_version) == TRUE)
        {
            gchar *update_msg = g_strdup_printf(
                _("There is a more recent version of Geany available: %s"),
                remote_version);
            dialogs_show_msgbox(GTK_MESSAGE_INFO, "%s", update_msg);
            g_message("%s", update_msg);
            g_free(update_msg);
        }
        else
        {
            const gchar *no_update_msg = _("No newer Geany version available.");
            if (type == UPDATECHECK_MANUAL)
            {
                dialogs_show_msgbox(GTK_MESSAGE_INFO, "%s", no_update_msg);
            }
            else
            {
                msgwin_status_add("%s", no_update_msg);
            }
            g_message("%s", no_update_msg);
        }
    }
    else
    {
        gchar *error_message = g_strdup_printf(
            _("Unable to perform version check.\nError code: %d \nError message: »%s«"),
            msg->status_code, msg->reason_phrase);
        if (type == UPDATECHECK_MANUAL)
        {
            dialogs_show_msgbox(GTK_MESSAGE_ERROR, "%s", error_message);
        }
        else
        {
            msgwin_status_add("%s", error_message);
        }
        g_warning("Connection error: Code: %d; Message: %s", msg->status_code, msg->reason_phrase);
        g_free(error_message);
    }
}
Пример #2
0
static void broker_init_failed(void)
{
	const gchar *err = enchant_broker_get_error(sc_speller_broker);
	dialogs_show_msgbox(GTK_MESSAGE_ERROR,
		_("The Enchant library couldn't be initialized (%s)."),
		(err != NULL) ? err : _("unknown error (maybe the chosen language is not available)"));
}
Пример #3
0
/* The function handles the menu item "New workbench" */
static void item_new_workbench_activate_cb(G_GNUC_UNUSED GtkMenuItem *menuitem, G_GNUC_UNUSED gpointer user_data)
{
	gchar *filename;
	GError *error = NULL;

	filename = dialogs_create_new_workbench();
	if (filename == NULL)
	{
		return;
	}
	wb_globals.opened_wb = workbench_new();
	workbench_set_filename(wb_globals.opened_wb, filename);
	if (workbench_save(wb_globals.opened_wb, &error))
	{
		menu_set_context(MENU_CONTEXT_WB_CREATED);
		sidebar_update(SIDEBAR_CONTEXT_WB_CREATED, NULL);
	}
	else
	{
		dialogs_show_msgbox(GTK_MESSAGE_INFO, _("Could not create new workbench file: %s"), error->message);
		workbench_free(wb_globals.opened_wb);
		wb_globals.opened_wb = NULL;
	}
	g_free(filename);
}
Пример #4
0
static void save_settings(void)
{
	GKeyFile *config = g_key_file_new();
	gchar    *data;
	gchar    *config_dir = g_path_get_dirname(config_file);

	g_key_file_load_from_file(config, config_file, G_KEY_FILE_NONE, NULL);

	g_key_file_set_boolean(config, "geanyprj", "display_sidebar", display_sidebar);

	if (! g_file_test(config_dir, G_FILE_TEST_IS_DIR) && utils_mkdir(config_dir, TRUE) != 0)
	{
		dialogs_show_msgbox(GTK_MESSAGE_ERROR,
			_("Plugin configuration directory could not be created."));
	}
	else
	{
		/* write config to file */
		data = g_key_file_to_data(config, NULL, NULL);
		utils_write_file(config_file, data);
		g_free(data);
	}
	g_free(config_dir);
	g_key_file_free(config);
}
Пример #5
0
/** 
 * name: cb_eval
 * 
 * This callback function is invoked when the 'LispEdit: eval' menu option is selected.
 * If the cursor is placed after a closing parenthesis the function will look for the matching
 * opening parenthesis. If there is no matching parenthesis it will display a warning dialog box.
 *  
 * If the closing parenthesis has a matching opening parenthesis, all the characters between the parentheses
 * including the parentheses are sent to the child process running in the VTE.
 * 
 * @param menuitem GtkMenuItem.
 * @param gdata gpointer.
 * @return void
 **/
static void cb_eval(G_GNUC_UNUSED GtkMenuItem *menuitem, G_GNUC_UNUSED gpointer gdata)
{
	if (have_vte)
    {
		doc = document_get_current();
		end_pos = sci_get_current_position(doc->editor->sci);
		if (end_pos > 0) end_pos--;
		gchar letter = sci_get_char_at(doc->editor->sci, end_pos);
		
		switch (letter)
		{ 
			case ')':	
						start_pos = sci_find_matching_brace(doc->editor->sci, end_pos);
						if (start_pos < 0)
						{
							dialogs_show_msgbox(GTK_MESSAGE_WARNING, "Found an isolated closing brace!!!");
						}
						else if (start_pos >= 0)
						{
							sci_get_text_range(doc->editor->sci, start_pos, ++end_pos, cmd_string);
							vte_terminal_feed_child(vte, "\n", strlen("\n"));
							vte_terminal_feed_child(vte, cmd_string, strlen(cmd_string));
							vte_terminal_feed_child(vte, "\n", strlen("\n"));
						}
						break;						
		}
    }
	else
	{
		show_error_message();
	}	
}
Пример #6
0
static void save_settings(void)
{
    GKeyFile *config = g_key_file_new();
    gchar *data;
    gchar *config_dir = g_path_get_dirname(config_file);

    g_key_file_load_from_file(config, config_file, G_KEY_FILE_NONE, NULL);

    g_key_file_set_integer(config, "geniuspaste", "website", website_selected);
    g_key_file_set_boolean(config, "geniuspaste", "open_browser", check_button_is_checked);
    g_key_file_set_string(config, "geniuspaste", "author_name", author_name);

    if (! g_file_test(config_dir, G_FILE_TEST_IS_DIR) && utils_mkdir(config_dir, TRUE) != 0)
    {
        dialogs_show_msgbox(GTK_MESSAGE_ERROR,
                            _("Plugin configuration directory could not be created."));
    }
    else
    {
        data = g_key_file_to_data(config, NULL, NULL);
        utils_write_file(config_file, data);
        g_free(data);
    }
    
    g_free(config_dir);
    g_key_file_free(config);
}
Пример #7
0
/*
 * opens position in a editor 
 */
void editor_open_position(const gchar *filename, int line)
{
	GeanyDocument* doc = NULL;
	gboolean already_open = (doc = document_get_current()) && !strcmp(DOC_FILENAME(doc), filename);

	if (!already_open)
		doc = document_open_file(filename, FALSE, NULL, NULL);

	if (doc)
	{
		/* temporarily set debug caret policy */
		scintilla_send_message(doc->editor->sci, SCI_SETYCARETPOLICY, CARET_SLOP | CARET_JUMPS | CARET_EVEN, 3);

		sci_goto_line(doc->editor->sci, line - 1, TRUE);

		/* revert to default edit caret policy */
		scintilla_send_message(doc->editor->sci, SCI_SETYCARETPOLICY, CARET_EVEN, 0);

		scintilla_send_message(doc->editor->sci, SCI_SETFOCUS, TRUE, 0);
	}
	else
	{
		dialogs_show_msgbox(GTK_MESSAGE_ERROR, _("Can't find a source file \"%s\""), filename);
	}
}
Пример #8
0
/* simple file print using an external tool */
static void print_external(GeanyDocument *doc)
{
	gchar *cmdline;

	if (doc->file_name == NULL)
		return;

	if (! NZV(printing_prefs.external_print_cmd))
	{
		dialogs_show_msgbox(GTK_MESSAGE_ERROR,
			_("Please set a print command in the preferences dialog first."));
		return;
	}

	cmdline = g_strdup(printing_prefs.external_print_cmd);
	utils_str_replace_all(&cmdline, "%f", doc->file_name);

	if (dialogs_show_question(
			_("The file \"%s\" will be printed with the following command:\n\n%s"),
			doc->file_name, cmdline))
	{
		GError *error = NULL;

#ifdef G_OS_WIN32
		gchar *tmp_cmdline = g_strdup(cmdline);
#else
		/* /bin/sh -c emulates the system() call and makes complex commands possible
		 * but only needed on non-win32 systems due to the lack of win32's shell capabilities */
		gchar *tmp_cmdline = g_strconcat("/bin/sh -c \"", cmdline, "\"", NULL);
#endif

		if (! g_spawn_command_line_async(tmp_cmdline, &error))
		{
			dialogs_show_msgbox(GTK_MESSAGE_ERROR,
				_("Printing of \"%s\" failed (return code: %s)."),
				doc->file_name, error->message);
			g_error_free(error);
		}
		else
		{
			msgwin_status_add(_("File %s printed."), doc->file_name);
		}
		g_free(tmp_cmdline);
	}
	g_free(cmdline);
}
Пример #9
0
gpgme_error_t geanypg_show_err_msg(gpgme_error_t err)
{
    gchar const * msg = (gchar const *)gpgme_strerror(err);
    gchar const * src = (gchar const *)gpgme_strsource(err);
    dialogs_show_msgbox(GTK_MESSAGE_ERROR, "%s %s: %s\n", _("Error from"), src, msg);
    fprintf(stderr, "GeanyPG: %s %s: %s\n", _("Error from"), msg, src);
    return err;
}
Пример #10
0
static void printing_print_gtk(GeanyDocument *doc)
{
	GtkPrintOperation *op;
	GtkPrintOperationResult res = GTK_PRINT_OPERATION_RESULT_ERROR;
	GError *error = NULL;
	DocInfo *dinfo;
	PrintWidgets *widgets;

	/** TODO check for monospace font, detect the widest character in the font and
	  * use it at font_width */

	widgets = g_new0(PrintWidgets, 1);
	dinfo = g_new0(DocInfo, 1);
	/* all other fields are initialised in begin_print() */
	dinfo->doc = doc;

	op = gtk_print_operation_new();

	gtk_print_operation_set_unit(op, GTK_UNIT_POINTS);
	gtk_print_operation_set_show_progress(op, TRUE);
#if GTK_CHECK_VERSION(2, 18, 0)
	gtk_print_operation_set_embed_page_setup(op, TRUE);
#endif

	g_signal_connect(op, "begin-print", G_CALLBACK(begin_print), dinfo);
	g_signal_connect(op, "end-print", G_CALLBACK(end_print), dinfo);
	g_signal_connect(op, "draw-page", G_CALLBACK(draw_page), dinfo);
	g_signal_connect(op, "status-changed", G_CALLBACK(status_changed), doc->file_name);
	g_signal_connect(op, "create-custom-widget", G_CALLBACK(create_custom_widget), widgets);
	g_signal_connect(op, "custom-widget-apply", G_CALLBACK(custom_widget_apply), widgets);

	if (settings != NULL)
		gtk_print_operation_set_print_settings(op, settings);
	if (page_setup != NULL)
		gtk_print_operation_set_default_page_setup(op, page_setup);

	res = gtk_print_operation_run(
		op, GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG, GTK_WINDOW(main_widgets.window), &error);

	if (res == GTK_PRINT_OPERATION_RESULT_APPLY)
	{
		if (settings != NULL)
			g_object_unref(settings);
		settings = g_object_ref(gtk_print_operation_get_print_settings(op));
		/* status message is printed in the status-changed handler */
	}
	else if (res == GTK_PRINT_OPERATION_RESULT_ERROR)
	{
		dialogs_show_msgbox(GTK_MESSAGE_ERROR, _("Printing of %s failed (%s)."),
							doc->file_name, error->message);
		g_error_free(error);
	}

	g_object_unref(op);
	g_free(dinfo);
	g_free(widgets);
}
Пример #11
0
gpgme_error_t geanypg_passphrase_cb(void *hook,
                                    const char *uid_hint,
                                    const char *passphrase_info,
                                    int prev_was_bad ,
                                    int fd)
{
    dialogs_show_msgbox(GTK_MESSAGE_ERROR, _("Error, Passphrase input without using gpg-agent is not supported on Windows yet."));
    return gpgme_err_make(GPG_ERR_SOURCE_PINENTRY, GPG_ERR_CANCELED);
}
Пример #12
0
static void
on_configure_response(G_GNUC_UNUSED GtkDialog *dialog, gint response, G_GNUC_UNUSED  gpointer user_data)
{
	if (response == GTK_RESPONSE_OK || response == GTK_RESPONSE_APPLY)
	{
		GKeyFile 	*config = g_key_file_new();
		gchar 		*config_dir = g_path_get_dirname(config_file);
		gboolean	configure_toogle_status;

		g_free(mailer);
		mailer = g_strdup(gtk_entry_get_text(GTK_ENTRY(pref_widgets.entry)));

		configure_toogle_status =
			gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(pref_widgets.checkbox_icon_to_toolbar));

		if (icon_in_toolbar ^ configure_toogle_status)
		/* Only do anything if a status change is needed */
		{
			if (icon_in_toolbar == TRUE)
			{
				/* We need to remove the toolbar icon */
				cleanup_icon();
			}
			else
			{
				/* We need to show the toolbar icon */
				show_icon();
			}
		}

		if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(pref_widgets.checkbox_use_addressdialog)) == TRUE)
			use_address_dialog = TRUE;
		else
			use_address_dialog = FALSE;

		g_key_file_load_from_file(config, config_file, G_KEY_FILE_NONE, NULL);
		g_key_file_set_string(config, "tools", "mailer", mailer);
		g_key_file_set_boolean(config, "tools", "address_usage", use_address_dialog);
		g_key_file_set_boolean(config, "icon", "show_icon", icon_in_toolbar);

		if (! g_file_test(config_dir, G_FILE_TEST_IS_DIR) && utils_mkdir(config_dir, TRUE) != 0)
		{
			dialogs_show_msgbox(GTK_MESSAGE_ERROR,
				_("Plugin configuration directory could not be created."));
		}
		else
		{
			/* write config to file */
			gchar *data = g_key_file_to_data(config, NULL, NULL);
			utils_write_file(config_file, data);
			g_free(data);
		}
		g_key_file_free(config);
		g_free(config_dir);
	}
}
Пример #13
0
void on_debug_auto_run(G_GNUC_UNUSED GArray *nodes)
{
	if (debug_auto_run && !thread_count)
	{
		if (breaks_active())
			debug_send_command(N, "-exec-run");
		else
			dialogs_show_msgbox(GTK_MESSAGE_INFO, _("No breakpoints. Hanging."));
	}
}
Пример #14
0
static void breaks_set_hits_count_debug(breakpoint* bp)
{
	if (debug_set_break(bp, BSA_UPDATE_HITS_COUNT))
	{
		on_set_hits_count(bp);
		/* mark config for saving */
		config_set_debug_changed();
	}
	else
		dialogs_show_msgbox(GTK_MESSAGE_ERROR, "%s", debug_error_message());
}
Пример #15
0
PLUGIN_EXPORT
void plugin_configure_single(GtkWidget *parent)
{
	if (glspi_configure) {
		glspi_configure(parent);
	} else {
		dialogs_show_msgbox(GTK_MESSAGE_ERROR,
			_("The %s plugin failed to load properly.\n"
			"Please check your installation."), PLUGIN_NAME );
	}
}
Пример #16
0
static void breaks_remove_debug(breakpoint* bp)
{
	if (debug_remove_break(bp))
	{
		/* remove markers, update treeview */
		on_remove(bp);
		/* mark config for saving */
		config_set_debug_changed();
	}
	else
		dialogs_show_msgbox(GTK_MESSAGE_ERROR, "%s", debug_error_message());
}
Пример #17
0
static void item_activate(GtkMenuItem * menuitem, gpointer gdata)
{
    GeanyDocument *doc = document_get_current();

    if(!DOC_VALID(doc))
    {
        dialogs_show_msgbox(GTK_MESSAGE_ERROR, _("There are no opened documents. Open one and retry.\n"));
        return;
    }

    paste(doc, websites_api[website_selected]);
}
Пример #18
0
/*
 * functions that are called when a breakpoint is altered while debuginng session is active.
 * Therefore, these functions try to alter break in debug session first and if successful -
 * do what on_... do or simply call on_... function directly
 */
static void breaks_add_debug(breakpoint* bp)
{
	if (debug_set_break(bp, BSA_NEW_BREAK))
	{
		/* add markers, update treeview */
		on_add(bp);
		/* mark config for saving */
		config_set_debug_changed();
	}
	else
		dialogs_show_msgbox(GTK_MESSAGE_ERROR, "%s", debug_error_message());
}
Пример #19
0
/* The function handles the menu item "Save workbench" */
static void item_save_workbench_activate_cb(G_GNUC_UNUSED GtkMenuItem *menuitem, G_GNUC_UNUSED gpointer user_data)
{
	GError *error = NULL;

	if (wb_globals.opened_wb != NULL)
	{
		if (!workbench_save(wb_globals.opened_wb, &error))
		{
			dialogs_show_msgbox(GTK_MESSAGE_INFO, _("Could not save workbench file: %s"), error->message);
		}
		sidebar_update(SIDEBAR_CONTEXT_WB_SAVED, NULL);
	}
}
Пример #20
0
/**
 * @brief load plugin's configuration or set default values
 * @param void 
 * @return void
 * 
 */
static void load_configuration(void)
{
	GKeyFile *config = NULL;
	gchar *config_filename = NULL;
	gchar **impl_list  = NULL, **head_list = NULL;
	gsize head_list_len, impl_list_len;
	gsize i;

	/* Load user configuration */ 
	config = g_key_file_new();
	config_filename = g_strconcat(geany->app->configdir, G_DIR_SEPARATOR_S,
		"plugins", G_DIR_SEPARATOR_S, "codenav", G_DIR_SEPARATOR_S, "codenav.conf", NULL);
	gboolean is_configured = g_key_file_load_from_file(config, config_filename, G_KEY_FILE_NONE, NULL);

	if ( is_configured ) {
		log_debug("Loading user configuration");
		impl_list = g_key_file_get_string_list(config, "switch_head_impl", "implementations_list", &impl_list_len, NULL);
		head_list = g_key_file_get_string_list(config, "switch_head_impl", "headers_list", &head_list_len, NULL);
		
		// Wrong lists
		if ( head_list_len != impl_list_len ) {
			dialogs_show_msgbox(GTK_MESSAGE_WARNING,
				_("Codenav head/impl lists should have been same length. " \
				  "Geany will use the default configuration."));
			fill_default_languages_list();
		}
		else
			fill_languages_list((const gchar**) impl_list, (const gchar**) head_list, head_list_len);
	}
	else {
		log_debug("Fresh configuration");
		fill_default_languages_list();
	}
	
	
	/* Freeing memory */
	g_key_file_free(config);
	g_free(config_filename);

	if ( impl_list != NULL ) {
		for ( i = 0; i < impl_list_len; i++ )
			g_free(impl_list[i]);
		g_free(impl_list);
	}
	if ( head_list != NULL ) {
		for ( i = 0; i < head_list_len; i++ )
			g_free(head_list[i]);
		g_free(head_list);
	}

}
Пример #21
0
static void breaks_switch_debug(breakpoint* bp)
{
	if (debug_set_break(bp, BSA_UPDATE_ENABLE))
	{
		on_switch(bp);
		/* mark config for saving */
		config_set_debug_changed();
	}
	else
	{
		bp->enabled = !bp->enabled;
		dialogs_show_msgbox(GTK_MESSAGE_ERROR, "%s", debug_error_message());
	}
}
Пример #22
0
static void broker_init_failed(void)
{
	const gchar *err = enchant_broker_get_error(sc_speller_broker);
	gchar *msg = g_strdup_printf(
		_("The Enchant library couldn't be initialized (%s)."),
		(err != NULL) ? err : _("unknown error (maybe the chosen language is not available)"));

	msgwin_status_add("%s", msg);
	if (main_is_realized())
		/* show dialog only after Geany has been loaded already, i.e. not while starting up */
		dialogs_show_msgbox(GTK_MESSAGE_ERROR, "%s", msg);

	g_free(msg);
}
Пример #23
0
static PyObject *
Dialogs_show_msgbox(PyObject *self, PyObject *args, PyObject *kwargs)
{
    gchar *text = NULL;
    gint msgtype = (gint) GTK_MESSAGE_INFO;
    static gchar *kwlist[] = { "text", "msgtype", NULL };

    if (PyArg_ParseTupleAndKeywords(args, kwargs, "s|i", kwlist, &text, &msgtype))
    {
        if (text != NULL)
        {
            dialogs_show_msgbox((GtkMessageType) msgtype, "%s", text);
            Py_RETURN_TRUE;
        }
    }
    Py_RETURN_NONE;
}
Пример #24
0
static void on_configure_response(GtkDialog * dialog, gint response, gpointer * user_data)
{
    if (response == GTK_RESPONSE_OK || response == GTK_RESPONSE_APPLY)
    {
        if(g_strcmp0(gtk_entry_get_text(GTK_ENTRY(widgets.author_entry)), "") == 0)
        {
            dialogs_show_msgbox(GTK_MESSAGE_ERROR, _("The author name field is empty!"));
        }
        else
        {
            website_selected = gtk_combo_box_get_active(GTK_COMBO_BOX(widgets.combo));
            check_button_is_checked = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widgets.check_button));
            SETPTR(author_name, g_strdup(gtk_entry_get_text(GTK_ENTRY(widgets.author_entry))));
            save_settings();
        }
    }
}
Пример #25
0
static void breaks_set_condition_debug(breakpoint* bp)
{
	if (debug_set_break(bp, BSA_UPDATE_CONDITION))
	{
		on_set_condition(bp);
		/* mark config for saving */
		config_set_debug_changed();
	}
	else
	{
		/* revert to old condition (taken from tree) */
		gchar* oldcondition = bptree_get_condition(bp);
		strcpy(bp->condition, oldcondition);
		g_free(oldcondition);
		/* show error message */
		dialogs_show_msgbox(GTK_MESSAGE_ERROR, "%s", debug_error_message());
	}
}
Пример #26
0
static void check_socket_permissions(void)
{
	GStatBuf socket_stat;

	if (g_lstat(socket_info.file_name, &socket_stat) == 0)
	{	/* If the user id of the process is not the same as the owner of the socket
		 * file, then ignore this socket and start a new session. */
		if (socket_stat.st_uid != getuid())
		{
			const gchar *msg = _(
	/* TODO maybe this message needs a rewording */
	"Geany tried to access the Unix Domain socket of another instance running as another user.\n"
	"This is a fatal error and Geany will now quit.");
			g_warning("%s", msg);
			dialogs_show_msgbox(GTK_MESSAGE_ERROR, "%s", msg);
			exit(1);
		}
	}
}
Пример #27
0
static void
on_configure_response(G_GNUC_UNUSED GtkDialog *dialog, gint response,
                      G_GNUC_UNUSED gpointer user_data)
{
    if (response == GTK_RESPONSE_OK || response == GTK_RESPONSE_APPLY)
    {
        GKeyFile *config = g_key_file_new();
        gchar *data;
        gchar *config_dir = g_path_get_dirname(config_file);

        config_file = g_strconcat(geany->app->configdir,
            G_DIR_SEPARATOR_S, "plugins", G_DIR_SEPARATOR_S,
            "updatechecker", G_DIR_SEPARATOR_S, "general.conf", NULL);

        /* Crabbing options that has been set */
        check_on_startup =
            gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(config_widgets.run_on_startup));

        /* write stuff to file */
        g_key_file_load_from_file(config, config_file, G_KEY_FILE_NONE, NULL);

        g_key_file_set_boolean(config, "general", "check_for_updates_on_startup",
            check_on_startup);

        if (!g_file_test(config_dir, G_FILE_TEST_IS_DIR)
            && utils_mkdir(config_dir, TRUE) != 0)
        {
            dialogs_show_msgbox(GTK_MESSAGE_ERROR,
                _("Plugin configuration directory could not be created."));
        }
        else
        {
            /* write config to file */
            data = g_key_file_to_data(config, NULL, NULL);
            utils_write_file(config_file, data);
            g_free(data);
        }

        g_free(config_dir);
        g_key_file_free(config);
    }
}
Пример #28
0
void geanypg_handle_signatures(encrypt_data * ed)
{
    int verified = 0;
    gpgme_verify_result_t vres = gpgme_op_verify_result(ed->ctx);
    if (vres)
    {
        gpgme_signature_t sig = vres->signatures;
        while (sig)
        {
            geanypg_check_sig(ed, sig);
            sig = sig->next;
            verified = 1;
        }
    }
    if (!verified)
    {
        fprintf(stderr, "GEANYPG: could not find verification results\n");
        dialogs_show_msgbox(GTK_MESSAGE_ERROR, "Error, could not find verification results");
    }
}
Пример #29
0
static void configure_response_cb(GtkDialog *dialog, gint response, gpointer user_data)
{
	if (response == GTK_RESPONSE_OK || response == GTK_RESPONSE_APPLY)
	{
		GKeyFile *config = g_key_file_new();
		gchar *data;
		gchar *config_dir = g_path_get_dirname(sc_info->config_file);
		GtkComboBox *combo = GTK_COMBO_BOX(g_object_get_data(G_OBJECT(dialog), "combo"));

		setptr(sc_info->default_language, gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(combo)));
#ifdef HAVE_ENCHANT_1_5
		setptr(sc_info->dictionary_dir, g_strdup(gtk_entry_get_text(GTK_ENTRY(
			g_object_get_data(G_OBJECT(dialog), "dict_dir")))));
#endif
		sc_speller_reinit_enchant_dict();

		sc_info->check_while_typing = (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(
			g_object_get_data(G_OBJECT(dialog), "check_type"))));

		sc_info->use_msgwin = (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(
			g_object_get_data(G_OBJECT(dialog), "check_msgwin"))));

		sc_info->show_toolbar_item = (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(
			g_object_get_data(G_OBJECT(dialog), "check_toolbar"))));

		sc_info->show_editor_menu_item = (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(
			g_object_get_data(G_OBJECT(dialog), "check_editor_menu"))));

		g_key_file_load_from_file(config, sc_info->config_file, G_KEY_FILE_NONE, NULL);
		if (sc_info->default_language != NULL) /* lang may be NULL */
			g_key_file_set_string(config, "spellcheck", "language", sc_info->default_language);
		g_key_file_set_boolean(config, "spellcheck", "check_while_typing",
			sc_info->check_while_typing);
		g_key_file_set_boolean(config, "spellcheck", "use_msgwin",
			sc_info->use_msgwin);
		g_key_file_set_boolean(config, "spellcheck", "show_toolbar_item",
			sc_info->show_toolbar_item);
		g_key_file_set_boolean(config, "spellcheck", "show_editor_menu_item",
			sc_info->show_editor_menu_item);
	   if (sc_info->dictionary_dir != NULL)
			g_key_file_set_string(config, "spellcheck", "dictionary_dir",
				sc_info->dictionary_dir);

		sc_gui_update_toolbar();
		sc_gui_update_menu();
		populate_dict_combo(combo);

		if (! g_file_test(config_dir, G_FILE_TEST_IS_DIR) && utils_mkdir(config_dir, TRUE) != 0)
		{
			dialogs_show_msgbox(GTK_MESSAGE_ERROR,
				_("Plugin configuration directory could not be created."));
		}
		else
		{
			/* write config to file */
			data = g_key_file_to_data(config, NULL, NULL);
			utils_write_file(sc_info->config_file, data);
			g_free(data);
		}
		g_free(config_dir);
		g_key_file_free(config);
	}
}
Пример #30
0
/* 
 * called from debugger module to show an error message box 
 */
static void on_debugger_error (const gchar* message)
{
	dialogs_show_msgbox(GTK_MESSAGE_ERROR, "%s", message);
}