1
1

1999-01-23 Miguel de Icaza <miguel@nuclecu.unam.mx>

* gcmd.c (ep_add_callback): Set Window's position to
	GTK_WIN_POS_MOUSE.
	(gnome_external_panelize): ditto.
	(gnome_filter_cmd): ditto.

	* gdialogs.c (file_progress_query_replace_policy): Set Window's
	position to GTK_WIN_POS_MOUSE.
	(file_progress_real_query_replace): ditto.
	(file_mask_dialog): ditto.

	* gdialogs.c: Tag the strings for localization.  Remove debugging
	messages.

	* gmain.c (gmc_window_setup_from_panel): Helper routine used to
	set the GTK_WIN_POS_MOUSE on a window and set the parent with
	gnome_dialog_set_parent (iff you have the WPanel * pointer to the
	parent).

	* gtools.c (query_dialog): Set the window position to GTK_WIN_POS_MOUSE.

	* gtkdtree.c (gtk_dtree_destroy): Kill the add_entry notification hook.
	(gtk_dtree_init): Install a notification function for treentry.
	removal.
	(entry_added_callback, entry_removed_callback): Implemented.  Now
	the tree is in sync with the panels and reload will update the
	tree correctly.

1999-01-23  Miguel de Icaza  <miguel@nuclecu.unam.mx>

	* treestore.c (tree_store_remove_entry_remove_hook): Missing
	function.  To remove a notification hook.
	(tree_store_notify_add, tree_store_add_entry_add_hook,
	tree_store_remove_entry_add_hook): New functions to notify of
	additions to the treestore.

	* tree.c (tree_destroy): Remove the callback hook when we go
	away.
Этот коммит содержится в:
Miguel de Icaza 1999-01-23 20:43:36 +00:00
родитель 9b10e9a6b0
Коммит 625f76e957
11 изменённых файлов: 228 добавлений и 37 удалений

Просмотреть файл

@ -1,3 +1,32 @@
1999-01-23 Miguel de Icaza <miguel@nuclecu.unam.mx>
* gcmd.c (ep_add_callback): Set Window's position to
GTK_WIN_POS_MOUSE.
(gnome_external_panelize): ditto.
(gnome_filter_cmd): ditto.
* gdialogs.c (file_progress_query_replace_policy): Set Window's
position to GTK_WIN_POS_MOUSE.
(file_progress_real_query_replace): ditto.
(file_mask_dialog): ditto.
* gdialogs.c: Tag the strings for localization. Remove debugging
messages.
* gmain.c (gmc_window_setup_from_panel): Helper routine used to
set the GTK_WIN_POS_MOUSE on a window and set the parent with
gnome_dialog_set_parent (iff you have the WPanel * pointer to the
parent).
* gtools.c (query_dialog): Set the window position to GTK_WIN_POS_MOUSE.
* gtkdtree.c (gtk_dtree_destroy): Kill the add_entry notification hook.
(gtk_dtree_init): Install a notification function for treentry.
removal.
(entry_added_callback, entry_removed_callback): Implemented. Now
the tree is in sync with the panels and reload will update the
tree correctly.
1999-01-22 Federico Mena Quintero <federico@nuclecu.unam.mx>
* gdesktop-icon.c (set_text): Update the call to

Просмотреть файл

@ -205,6 +205,8 @@ gnome_sort_cmd (GtkWidget *widget, WPanel *panel)
sort_box = gnome_dialog_new (_("Sort By"), GNOME_STOCK_BUTTON_OK,
GNOME_STOCK_BUTTON_CANCEL, NULL);
gmc_window_setup_from_panel (GNOME_DIALOG (sort_box), panel);
/* we define this up here so we can pass it in to our callback */
cbox1 = gtk_check_button_new_with_label (N_("Ignore case sensitivity."));
hbox = gtk_hbox_new (FALSE, 0);
@ -323,6 +325,7 @@ get_nickname (gchar *text)
dlg = gnome_dialog_new (_("Enter name."), GNOME_STOCK_BUTTON_OK,
GNOME_STOCK_BUTTON_CANCEL, NULL);
gtk_window_set_position (GTK_WINDOW (dlg), GTK_WIN_POS_MOUSE);
entry = gtk_entry_new ();
if (text)
gtk_entry_set_text (GTK_ENTRY (entry), text);
@ -468,7 +471,8 @@ gnome_external_panelize (GtkWidget *widget, WPanel *panel)
data->selected = -1;
data->ep_dlg = gnome_dialog_new (_("Run Command"), GNOME_STOCK_BUTTON_OK,
GNOME_STOCK_BUTTON_CANCEL, NULL);
gtk_window_set_position (GTK_WINDOW (data->ep_dlg), GTK_WIN_POS_MOUSE);
/* Frame 1 */
frame = gtk_frame_new (_("Preset Commands"));
gtk_box_pack_start (GTK_BOX (GNOME_DIALOG (data->ep_dlg)->vbox),
@ -552,6 +556,7 @@ gnome_filter_cmd (GtkWidget *widget, WPanel *panel)
filter_dlg = gnome_dialog_new (_("Set Filter"), GNOME_STOCK_BUTTON_OK,
GNOME_STOCK_BUTTON_CANCEL, NULL);
gtk_window_set_position (GTK_WINDOW (filter_dlg), GTK_WIN_POS_MOUSE);
if (easy_patterns) {
text1 = "mc_filter_globs";
text3 = _("Show all files");

Просмотреть файл

@ -55,14 +55,12 @@ typedef struct {
GtkWidget *op_radio;
} FileOpContextUI;
static char *gdialog_to_string = N_("To: ");
static char *gdialog_from_string = N_("Copying from: ");
static char *gdialog_deleting_string = N_("Deleting file: ");
#define GDIALOG_TO_STRING "To: "
#define GDIALOG_FROM_STRING "Copying from: "
#define GDIALOG_DELETING_STRING "Deleting file: "
#define GDIALOG_PROGRESS_WIDTH 350
/* Callbacks go here... */
static void
fmd_check_box_callback (GtkWidget *widget, gpointer data)
@ -124,7 +122,7 @@ file_progress_show_source (FileOpContext *ctx, char *path)
if (!from_width){
from_width = gdk_string_width (ui->op_source_label->style->font,
_(GDIALOG_FROM_STRING));
_(gdialog_from_string));
}
path_width = gdk_string_width (ui->op_source_label->style->font, path);
if (from_width + path_width < GDIALOG_PROGRESS_WIDTH)
@ -165,7 +163,7 @@ file_progress_show_target (FileOpContext *ctx, char *path)
if (!to_width)
to_width = gdk_string_width (ui->op_target_label->style->font,
_(GDIALOG_TO_STRING));
_(gdialog_to_string));
path_width = gdk_string_width (ui->op_target_label->style->font, path);
if (to_width + path_width < GDIALOG_PROGRESS_WIDTH)
gtk_label_set_text (GTK_LABEL (ui->op_target_label), path);
@ -201,7 +199,7 @@ file_progress_show_deleting (FileOpContext *ctx, char *path)
if (!deleting_width){
deleting_width = gdk_string_width (ui->op_source_label->style->font,
_(GDIALOG_DELETING_STRING));
_(gdialog_deleting_string));
}
path_width = gdk_string_width (ui->op_source_label->style->font, path);
if (deleting_width + path_width < GDIALOG_PROGRESS_WIDTH)
@ -305,7 +303,6 @@ policy_callback (GtkWidget *button, gpointer data)
status = GPOINTER_TO_INT (gtk_object_get_user_data (GTK_OBJECT (button)));
if (GTK_TOGGLE_BUTTON (button)->active) {
g_print ("toggle\n");
if (status == REPLACE_OPTION_MENU) {
ui->copy_status = ui->minor_copy_status;
} else
@ -341,11 +338,11 @@ file_progress_query_replace_policy (FileOpContext *ctx, gboolean dialog_needed)
if (dialog_needed == FALSE)
return FILE_CONT;
ui->minor_copy_status = REPLACE_ALWAYS;
g_print ("in file_progress_query_replace_policy\n");
qrp_dlg = gnome_dialog_new (_("Files Exist"),
GNOME_STOCK_BUTTON_OK,
GNOME_STOCK_BUTTON_CANCEL,
NULL);
gtk_window_set_position (GTK_WINDOW (qrp_dlg), GTK_WIN_POS_MOUSE);
vbox = gtk_vbox_new (FALSE, GNOME_PAD_SMALL);
hbox = gtk_hbox_new (FALSE, GNOME_PAD_SMALL);
icon = gnome_stock_pixmap_widget (hbox, GNOME_STOCK_PIXMAP_HELP);
@ -454,6 +451,7 @@ file_progress_real_query_replace (FileOpContext *ctx, enum OperationMode mode, c
GNOME_STOCK_BUTTON_NO,
GNOME_STOCK_BUTTON_CANCEL, NULL);
gtk_window_set_position (GTK_WINDOW (qr_dlg), GTK_WIN_POS_MOUSE);
snprintf (msg, sizeof (msg)-1, _("The target file already exists: %s"), destname);
label = gtk_label_new (msg);
gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
@ -538,6 +536,8 @@ file_mask_dialog (FileOpContext *ctx, FileOperation operation, char *text, char
fmd_win = gnome_dialog_new (_("Move"), GNOME_STOCK_BUTTON_OK,
GNOME_STOCK_BUTTON_CANCEL, NULL);
gtk_window_set_position (GTK_WINDOW (fmd_win), GTK_WIN_POS_MOUSE);
hbox = gtk_hbox_new (FALSE, GNOME_PAD);
notebook = gtk_notebook_new ();
gtk_box_pack_start (GTK_BOX (GNOME_DIALOG (fmd_win)->vbox),
@ -731,15 +731,16 @@ file_op_context_create_ui (FileOpContext *ctx, FileOperation op, int with_eta)
switch (op) {
case OP_MOVE:
ui->op_win = gnome_dialog_new ("Move Progress", GNOME_STOCK_BUTTON_CANCEL, NULL);
ui->op_win = gnome_dialog_new (_("Move Progress"), GNOME_STOCK_BUTTON_CANCEL, NULL);
break;
case OP_COPY:
ui->op_win = gnome_dialog_new ("Copy Progress", GNOME_STOCK_BUTTON_CANCEL, NULL);
ui->op_win = gnome_dialog_new (_("Copy Progress"), GNOME_STOCK_BUTTON_CANCEL, NULL);
break;
case OP_DELETE:
ui->op_win = gnome_dialog_new ("Delete Progress", GNOME_STOCK_BUTTON_CANCEL, NULL);
ui->op_win = gnome_dialog_new (_("Delete Progress"), GNOME_STOCK_BUTTON_CANCEL, NULL);
break;
}
gtk_window_set_position (GTK_WINDOW (ui->op_win), GTK_WIN_POS_MOUSE);
gnome_dialog_button_connect (GNOME_DIALOG (ui->op_win), 0,
GTK_SIGNAL_FUNC (cancel_cb), ui);
@ -748,7 +749,7 @@ file_op_context_create_ui (FileOpContext *ctx, FileOperation op, int with_eta)
alignment = gtk_alignment_new (0.0, 0.5, 0, 0);
hbox = gtk_hbox_new (FALSE, 0);
gtk_container_add (GTK_CONTAINER (alignment), hbox);
gtk_box_pack_start (GTK_BOX (hbox), gtk_label_new (_(GDIALOG_FROM_STRING)), FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (hbox), gtk_label_new (_(gdialog_from_string)), FALSE, FALSE, 0);
ui->op_source_label = gtk_label_new ("");
gtk_box_pack_start (GTK_BOX (hbox), ui->op_source_label, FALSE, FALSE, 0);
@ -760,7 +761,7 @@ file_op_context_create_ui (FileOpContext *ctx, FileOperation op, int with_eta)
alignment = gtk_alignment_new (0.0, 0.5, 0, 0);
hbox = gtk_hbox_new (FALSE, 0);
gtk_container_add (GTK_CONTAINER (alignment), hbox);
gtk_box_pack_start (GTK_BOX (hbox), gtk_label_new (_(GDIALOG_TO_STRING)), FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (hbox), gtk_label_new (_(gdialog_to_string)), FALSE, FALSE, 0);
ui->op_target_label = gtk_label_new ("");
gtk_box_pack_start (GTK_BOX (hbox), ui->op_target_label, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (GNOME_DIALOG (ui->op_win)->vbox),
@ -770,7 +771,7 @@ file_op_context_create_ui (FileOpContext *ctx, FileOperation op, int with_eta)
alignment = gtk_alignment_new (0.0, 0.5, 0, 0);
hbox = gtk_hbox_new (FALSE, 0);
gtk_container_add (GTK_CONTAINER (alignment), hbox);
gtk_box_pack_start (GTK_BOX (hbox), gtk_label_new (_(GDIALOG_DELETING_STRING)), FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (hbox), gtk_label_new (_(gdialog_deleting_string)), FALSE, FALSE, 0);
ui->op_source_label = gtk_label_new ("");
gtk_box_pack_start (GTK_BOX (hbox), ui->op_source_label, FALSE, FALSE, 0);

Просмотреть файл

@ -626,3 +626,15 @@ session_management_setup (char *name)
}
}
/*
* Configures the GtkWindow/GnomeDialog from a WPanel.
*
* This makes the window centered on the screen and binds it to
* its parent container for better window manager experience
*/
void
gmc_window_setup_from_panel (GnomeDialog *dialog, WPanel *panel)
{
gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_MOUSE);
gnome_dialog_set_parent (dialog, GTK_WINDOW (panel->xwindow));
}

Просмотреть файл

@ -41,6 +41,8 @@ int gmc_view (char *filename, int start_line);
void x_show_info (WInfo *info, struct my_statfs *s, struct stat *b);
void x_create_info (Dlg_head *h, widget_data parent, WInfo *info);
void gmc_window_setup_from_panel (GnomeDialog *dialog, WPanel *panel);
struct gmc_color_pairs_s {
GdkColor *fore, *back;
};

Просмотреть файл

@ -99,6 +99,24 @@ gtk_dtree_contains (GtkDTree *dtree, GtkCTreeNode *parent, char *text)
return NULL;
}
static GtkCTreeNode *
gtk_dtree_insert_node (GtkDTree *dtree, GtkCTreeNode *parent, char *text)
{
GtkCTreeNode *sibling;
char *texts [1];
texts [0] = text;
sibling = gtk_ctree_insert_node (
GTK_CTREE (dtree), parent, NULL,
texts, TREE_SPACING,
dtree->pixmap_close,
dtree->bitmap_close,
dtree->pixmap_open,
dtree->bitmap_open,
FALSE, FALSE);
}
static gboolean
gtk_dtree_load_path (GtkDTree *dtree, char *path, GtkCTreeNode *parent, int level)
{
@ -115,24 +133,15 @@ gtk_dtree_load_path (GtkDTree *dtree, char *path, GtkCTreeNode *parent, int leve
for (; (dirent = tree_store_readdir (dir)) != NULL; ){
GtkCTreeNode *sibling;
char *text [1];
char *text;
text [0] = x_basename (dirent->name);
text = x_basename (dirent->name);
/* Do not insert duplicates */
sibling = gtk_dtree_contains (dtree, parent, text [0]);
sibling = gtk_dtree_contains (dtree, parent, text);
if (sibling == NULL){
sibling = gtk_ctree_insert_node (
GTK_CTREE (dtree), parent, NULL,
text, TREE_SPACING,
dtree->pixmap_close,
dtree->bitmap_close,
dtree->pixmap_open,
dtree->bitmap_open,
FALSE, FALSE);
}
if (sibling == NULL)
sibling = gtk_dtree_insert_node (dtree, parent, text);
if (level)
gtk_dtree_load_path (dtree, dirent->name, sibling, level-1);
@ -354,11 +363,77 @@ gtk_dtree_expand (GtkCTree *ctree, GtkCTreeNode *node)
gtk_dtree_select_row (ctree, node, 0);
}
/*
* entry_removed_callback:
*
* Called when an entry is removed by the treestore
*/
static void
entry_removed_callback (tree_entry *tree, void *data)
{
GtkCTreeNode *current_node;
GtkDTree *dtree = data;
char *dirname, *copy, *current ;
copy = dirname = g_strdup (tree->name);
copy++;
current_node = dtree->root_node;
while ((current = strtok (copy, "/")) != NULL){
current_node = gtk_dtree_lookup_dir (dtree, current_node, current);
if (!current_node)
break;
copy = NULL;
}
if (current == NULL && current_node)
gtk_ctree_remove_node (GTK_CTREE (data), current_node);
g_free (dirname);
}
/*
* entry_added_callback:
*
* Callback invoked by the treestore when a tree_entry has been inserted
* into the treestore. We update the gtkdtree with this new information.
*/
static void
entry_added_callback (tree_entry *tree, void *data)
{
GtkCTreeNode *current_node, *new_node;
GtkDTree *dtree = data;
char *dirname, *copy, *current, *npath, *full_path;
copy = dirname = g_strdup (tree->name);
copy++;
current_node = dtree->root_node;
npath = g_strdup ("/");
while ((current = strtok (copy, "/")) != NULL){
full_path = g_concat_dir_and_file (npath, current);
g_free (npath);
npath = full_path;
new_node = gtk_dtree_lookup_dir (dtree, current_node, current);
if (!new_node){
GtkCTreeNode *sibling;
sibling = gtk_dtree_insert_node (dtree, current_node, current);
gtk_dtree_load_path (dtree, full_path, sibling, 1);
break;
}
copy = NULL;
current_node = new_node;
}
g_free (npath);
g_free (dirname);
}
static void
gtk_dtree_destroy (GtkObject *object)
{
GtkDTree *dtree = GTK_DTREE (object);
tree_store_remove_entry_remove_hook (entry_removed_callback);
tree_store_remove_entry_add_hook (entry_added_callback);
gdk_pixmap_unref (dtree->pixmap_open);
gdk_pixmap_unref (dtree->pixmap_close);
gdk_bitmap_unref (dtree->bitmap_open);
@ -505,6 +580,9 @@ gtk_dtree_init (GtkDTree *dtree)
dtree->auto_expanded_nodes = NULL;
tree_store_dirty_notify = gtk_dtree_dirty_notify;
tree_store_add_entry_remove_hook (entry_removed_callback, dtree);
tree_store_add_entry_add_hook (entry_added_callback, dtree);
}
void

Просмотреть файл

@ -42,7 +42,7 @@ int query_dialog (char *header, char *text, int flags, int count, ...)
WLabel *label;
GtkWidget *dialog;
int i, result = -1;
gchar **buttons;
const gchar **buttons;
char *stock;
GSList *allocated = NULL;
@ -76,7 +76,8 @@ int query_dialog (char *header, char *text, int flags, int count, ...)
buttons[i] = NULL;
dialog = gnome_message_box_newv (text, header, buttons);
gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_MOUSE);
result = gnome_dialog_run_and_close (GNOME_DIALOG (dialog));
g_slist_foreach (allocated, (GFunc) g_free, NULL);

Просмотреть файл

@ -1,3 +1,14 @@
1999-01-23 Miguel de Icaza <miguel@nuclecu.unam.mx>
* treestore.c (tree_store_remove_entry_remove_hook): Missing
function. To remove a notification hook.
(tree_store_notify_add, tree_store_add_entry_add_hook,
tree_store_remove_entry_add_hook): New functions to notify of
additions to the treestore.
* tree.c (tree_destroy): Remove the callback hook when we go
away.
1999-01-21 Miguel de Icaza <miguel@nuclecu.unam.mx>
* option.c (init_configure): One line patch from Alexander

Просмотреть файл

@ -164,7 +164,7 @@ void tree_remove_entry (WTree *tree, char *name)
void tree_destroy (WTree *tree)
{
tree_store_remove_entry_remove_hook (remove_callback);
save_tree (tree);
tree_store_destroy ();

Просмотреть файл

@ -560,9 +560,11 @@ tree_store_mark_checked (const char *subname)
while (current && (flag = pathcmp (current->name, name)) < 0)
current = current->next;
if (flag != 0)
if (flag != 0){
/* Doesn't exist -> add it */
current = tree_store_add_entry (name);
tree_store_notify_add (current);
}
free (name);
/* Clear the deletion mark from the subdirectory and its children */
@ -646,6 +648,8 @@ tree_store_end_check (void)
if (!ts.loaded)
return;
g_return_if_fail (ts.check_name);
/* Check delete marks and delete if found */
len = strlen (ts.check_name);
@ -702,6 +706,7 @@ tree_store_rescan (char *dir)
}
static Hook *remove_entry_hooks;
static Hook *add_entry_hooks;
void
tree_store_add_entry_remove_hook (tree_store_remove_fn callback, void *data)
@ -709,6 +714,12 @@ tree_store_add_entry_remove_hook (tree_store_remove_fn callback, void *data)
add_hook (&remove_entry_hooks, (void (*)(void *))callback, data);
}
void
tree_store_remove_entry_remove_hook (tree_store_remove_fn callback)
{
delete_hook (&remove_entry_hooks, (void (*)(void *))callback);
}
void
tree_store_notify_remove (tree_entry *entry)
{
@ -723,6 +734,32 @@ tree_store_notify_remove (tree_entry *entry)
}
}
void
tree_store_add_entry_add_hook (tree_store_add_fn callback, void *data)
{
add_hook (&add_entry_hooks, (void (*)(void *))callback, data);
}
void
tree_store_remove_entry_add_hook (tree_store_add_fn callback)
{
delete_hook (&add_entry_hooks, (void (*)(void *))callback);
}
void
tree_store_notify_add (tree_entry *entry)
{
Hook *p = add_entry_hooks;
tree_store_add_fn r;
while (p){
r = (tree_store_add_fn) p->hook_fn;
r (entry, p->hook_data);
p = p->next;
}
}
tree_scan *
tree_store_opendir (char *path)
{

Просмотреть файл

@ -44,10 +44,25 @@ void tree_store_end_check (void);
tree_entry *tree_store_whereis (char *name);
tree_entry *tree_store_rescan (char *dir);
/*
* Register/unregister notification functions for "entry_remove"
*/
typedef void (*tree_store_remove_fn)(tree_entry *tree, void *data);
void tree_store_add_entry_remove_hook (tree_store_remove_fn callback, void *data);
void tree_store_add_entry_remove_hook (tree_store_remove_fn callback, void *data);
void tree_store_remove_entry_remove_hook (tree_store_remove_fn callback);
void tree_store_notify_remove (tree_entry *entry);
/*
* Register/unregister notification functions for "entry_remove"
*/
typedef void (*tree_store_add_fn)(tree_entry *tree, void *data);
void tree_store_add_entry_add_hook (tree_store_remove_fn callback, void *data);
void tree_store_remove_entry_add_hook (tree_store_remove_fn callback);
/*
* Changes in the tree_entry are notified with these
*/
void tree_store_notify_remove (tree_entry *entry);
void tree_store_notify_add (tree_entry *entry);
tree_scan *tree_store_opendir (char *path);
tree_entry *tree_store_readdir (tree_scan *scanner);