⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dialog-plugins.c

📁 一个简单的文本编辑器
💻 C
📖 第 1 页 / 共 2 页
字号:
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- *//* * gedit * * Copyright (C) 2000 Jose M Celorio * * 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 2 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, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. */#include <config.h>#include <glib.h>#include <string.h> /* For strlen and strcmp */#include <gnome.h>#include <glade/glade.h>#include "file.h"#include "plugin.h"#include "document.h"#include "utils.h"#include "window.h"#include "dialogs/dialogs.h"#define GEDIT_PLUGIN_MANAGER_GLADE_FILE "plugin-manager.glade"GtkWidget *installed_list;GtkWidget *available_list;gint text_length = 0;/*#define OLD_CLEAR*//** * gedit_plugin_email_sendmail_location_dialog: * @void:  *  * it displays and pop-up a dialog so that the user can specify a * location for an auxiliary program for a plugin (sendmail,diff,lynx) *  * Return Value: a string with the path specified by the user **/gchar *gedit_plugin_program_location_dialog (gchar *program_name, gchar *plugin_name){	GladeXML *gui;	GtkWidget *program_location_dialog = NULL;	GtkWidget *program_location_entry = NULL;	GtkWidget *program_location_combo_entry = NULL;	GtkWidget *label = NULL;	gchar *str_label;		gchar * location = NULL;	gedit_debug (DEBUG_PLUGINS, "");	gui = glade_xml_new (GEDIT_GLADEDIR "/program.glade", NULL);	if (!gui)	{		g_warning ("Could not find program.glade");		return NULL;	}	program_location_dialog = glade_xml_get_widget (gui, "program_location_dialog");	program_location_entry  = glade_xml_get_widget (gui, "program_location_file_entry");	program_location_combo_entry  = glade_xml_get_widget (gui, "combo-entry1");	label = glade_xml_get_widget (gui, "label");	if (!program_location_dialog || !program_location_entry || 	    !label || !program_location_combo_entry)	{		g_warning ("Could not get the program location dialog from program.glade");		return NULL;	}	str_label = g_strdup_printf(_("To use the %s plugin, you need to specify a location for \"%s\"."),			plugin_name, program_name);	gtk_label_set_text (GTK_LABEL (label), str_label);	g_free(str_label);	gnome_dialog_set_default     (GNOME_DIALOG (program_location_dialog), 0);	gnome_dialog_editable_enters (GNOME_DIALOG (program_location_dialog), 				      GTK_EDITABLE (program_location_combo_entry));		/* If we do this the main plugin dialog goes below the program window. Chema.	*/	switch (gnome_dialog_run (GNOME_DIALOG (program_location_dialog)))	{	case 0:		location = gnome_file_entry_get_full_path(GNOME_FILE_ENTRY(program_location_entry), FALSE);		gnome_dialog_close (GNOME_DIALOG(program_location_dialog));		break;	case 1:		gnome_dialog_close (GNOME_DIALOG(program_location_dialog));		break;	default:		location = NULL;		break;	}	gtk_object_unref (GTK_OBJECT (gui));	return location;}static voidgedit_plugin_manager_info_clear (GtkWidget *widget){	gedit_debug (DEBUG_PLUGINS, "");	g_return_if_fail (widget != NULL);	g_return_if_fail (GTK_IS_EDITABLE(widget));		if (text_length > 0)		gtk_editable_delete_text (GTK_EDITABLE(widget), 0, text_length);	text_length = 0;}static voidgedit_plugin_manager_lists_thaw (GtkWidget *widget){	gedit_debug (DEBUG_PLUGINS, "");	gtk_clist_unselect_all (GTK_CLIST (installed_list));	gtk_clist_unselect_all (GTK_CLIST (available_list));#if 0 	g_print ("A:%i I:%i\n",		 GTK_CLIST (available_list)->rows,		 GTK_CLIST (installed_list)->rows);#endif	gtk_clist_thaw (GTK_CLIST (available_list));	gtk_clist_thaw (GTK_CLIST (installed_list));	gedit_plugin_manager_info_clear (widget);}static voidgedit_plugin_manager_lists_freeze (void){	gedit_debug (DEBUG_PLUGINS, "");	gtk_clist_freeze (GTK_CLIST (installed_list));	gtk_clist_freeze (GTK_CLIST (available_list));}static gint gedit_plugin_manager_clist_compare_function (GtkCList *clist, GtkCListRow *row_1, GtkCListRow *row_2){	gchar *string_1 = ((GtkCellText*)&(row_1->cell[clist->sort_column]))->text;	gchar *string_2 = ((GtkCellText*)&(row_2->cell[clist->sort_column]))->text;	gedit_debug (DEBUG_PLUGINS, "");	g_return_val_if_fail (string_1 != NULL, -1);	g_return_val_if_fail (string_2 != NULL, -1);		return strcmp (string_1, string_2);}static voidgedit_plugin_manager_item_load (GtkWidget *widget){	gint n;	gint row;	PluginData *nth_plugin_data;	gpointer row_data;	gchar * name[2];	gedit_debug (DEBUG_PLUGINS, "");	gedit_plugin_manager_lists_freeze ();		for (n=0; n < g_list_length (plugins_list); n++)	{		nth_plugin_data = g_list_nth_data (plugins_list, n);		name[0] = g_strdup (nth_plugin_data->name);		name[1] = NULL;				row_data = (gpointer) nth_plugin_data;		if (nth_plugin_data->installed)		{			row = gtk_clist_append (GTK_CLIST(installed_list),						name);			gtk_clist_set_row_data (GTK_CLIST(installed_list),						row, row_data);		}		else		{			row = gtk_clist_append (GTK_CLIST(available_list),						name);			gtk_clist_set_row_data (GTK_CLIST(available_list),						row, row_data);		}		if (name[0] != NULL)			g_free (name[0]);	}	gtk_clist_set_compare_func (GTK_CLIST (installed_list),				    (GtkCListCompareFunc) gedit_plugin_manager_clist_compare_function);	gtk_clist_set_compare_func (GTK_CLIST (available_list),				    (GtkCListCompareFunc) gedit_plugin_manager_clist_compare_function);		gtk_clist_set_sort_column (GTK_CLIST (installed_list), 0);	gtk_clist_set_sort_column (GTK_CLIST (available_list), 0);	gtk_clist_set_auto_sort (GTK_CLIST (installed_list), TRUE);	gtk_clist_set_auto_sort (GTK_CLIST (available_list), TRUE);	gedit_plugin_manager_lists_thaw (widget);}static voidgedit_plugin_manager_item_add (GtkWidget *widget, gpointer data){	gint n;	gint row;	gint selection_length;	gchar *name;	gchar *name_array[2];	gpointer item_data;	gint last_element_hack = FALSE;	gedit_debug (DEBUG_PLUGINS, "");	selection_length = g_list_length (GTK_CLIST (available_list)->selection);	gedit_plugin_manager_lists_freeze();	if (selection_length == 0 && GTK_CLIST (available_list)->rows == 0)		last_element_hack = TRUE;	for (n=0; n < selection_length; n++)	{		row = (gint) g_list_nth_data (GTK_CLIST (available_list)->selection, n);		gtk_clist_get_text (GTK_CLIST (available_list), row, 0, &name);		item_data = gtk_clist_get_row_data (GTK_CLIST(available_list), row);		name_array[0] = g_strdup(name);		name_array[1] = NULL;		if (!last_element_hack)			gtk_clist_remove (GTK_CLIST (available_list), row);		row = gtk_clist_append (GTK_CLIST (installed_list), name_array);		gtk_clist_set_row_data (GTK_CLIST (installed_list), row, item_data);		if (name_array[0] != NULL)			g_free (name_array[0]);	}	if (last_element_hack)		gtk_clist_clear (GTK_CLIST(available_list));				gedit_plugin_manager_lists_thaw (GTK_WIDGET(data));}static voidgedit_plugin_manager_item_remove (GtkWidget *widget, gpointer data){	gint n;	gint row;	gint selection_length;	gchar *name;	gchar *name_array[2];	gpointer item_data;	gint last_element_hack = FALSE;	gedit_debug (DEBUG_PLUGINS, "");	selection_length = g_list_length (GTK_CLIST (installed_list)->selection);	gedit_plugin_manager_lists_freeze();	if (selection_length == 0 && GTK_CLIST (installed_list)->rows == 0)		last_element_hack = TRUE;	for (n=0; n < selection_length; n++)	{		row = (gint) g_list_nth_data (GTK_CLIST (installed_list)->selection, n);		gtk_clist_get_text (GTK_CLIST (installed_list), row, 0, &name);		item_data = gtk_clist_get_row_data (GTK_CLIST(installed_list), row);		name_array[0] = g_strdup(name);		name_array[1] = NULL;		if (!last_element_hack)			gtk_clist_remove (GTK_CLIST (installed_list), row);				row = gtk_clist_append (GTK_CLIST (available_list), name_array);		gtk_clist_set_row_data (GTK_CLIST (available_list), row, item_data);		if (name_array[0] != NULL)			g_free (name_array [0]);	}	if (last_element_hack)		gtk_clist_clear (GTK_CLIST(installed_list));		gedit_plugin_manager_lists_thaw (GTK_WIDGET(data));}static voidgedit_plugin_manager_item_add_all (GtkWidget *widget, gpointer data)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -