Compare commits
6 Commits
4d6d2e6734
...
8be5bd230b
Author | SHA1 | Date | |
---|---|---|---|
8be5bd230b | |||
3a72796b2f | |||
9f7e1e1696 | |||
27f5a5e3d2 | |||
ec72fb2aa1 | |||
4968492eee |
@ -586,6 +586,34 @@ static void on_select_all_layers_clicked(GtkWidget *button, gpointer user_data)
|
||||
layer_selector_select_all_layers(gui->layer_selector, TRUE);
|
||||
}
|
||||
|
||||
static void auto_naming_clicked(GtkWidget *button, gpointer user_data)
|
||||
{
|
||||
GdsRenderGui *gui;
|
||||
GtkDialog *dialog;
|
||||
gboolean overwrite;
|
||||
int dialog_result;
|
||||
(void)button;
|
||||
|
||||
gui = RENDERER_GUI(user_data);
|
||||
|
||||
/* Ask for overwrite */
|
||||
dialog = GTK_DIALOG(gtk_message_dialog_new(gui->main_window, GTK_DIALOG_USE_HEADER_BAR, GTK_MESSAGE_QUESTION,
|
||||
GTK_BUTTONS_YES_NO, "Overwrite existing layer names?"));
|
||||
dialog_result = gtk_dialog_run(dialog);
|
||||
switch (dialog_result) {
|
||||
case GTK_RESPONSE_YES:
|
||||
overwrite = TRUE;
|
||||
break;
|
||||
case GTK_RESPONSE_NO: /* Expected fallthrough */
|
||||
default:
|
||||
overwrite = FALSE;
|
||||
break;
|
||||
}
|
||||
gtk_widget_destroy(GTK_WIDGET(dialog));
|
||||
|
||||
layer_selector_auto_name_layers(gui->layer_selector, overwrite);
|
||||
}
|
||||
|
||||
GtkWindow *gds_render_gui_get_main_window(GdsRenderGui *gui)
|
||||
{
|
||||
return gui->main_window;
|
||||
@ -601,6 +629,7 @@ static void gds_render_gui_init(GdsRenderGui *self)
|
||||
GtkWidget *sort_down_button;
|
||||
GtkWidget *activity_bar_box;
|
||||
GtkWidget *auto_color_button;
|
||||
GtkWidget *auto_naming_button;
|
||||
|
||||
main_builder = gtk_builder_new_from_resource("/gui/main.glade");
|
||||
|
||||
@ -672,6 +701,10 @@ static void gds_render_gui_init(GdsRenderGui *self)
|
||||
self->select_all_button = GTK_WIDGET(gtk_builder_get_object(main_builder, "button-select-all"));
|
||||
g_signal_connect(self->select_all_button, "clicked", G_CALLBACK(on_select_all_layers_clicked), self);
|
||||
|
||||
/* Setup auto naming button */
|
||||
auto_naming_button = GTK_WIDGET(gtk_builder_get_object(main_builder, "button-auto-name"));
|
||||
g_signal_connect(auto_naming_button, "clicked", G_CALLBACK(auto_naming_clicked), self);
|
||||
|
||||
g_object_unref(main_builder);
|
||||
|
||||
/* Setup default button sensibility data */
|
||||
|
@ -103,10 +103,21 @@ void layer_selector_select_all_layers(LayerSelector *layer_selector, gboolean se
|
||||
* @brief Apply colors from palette to all layers. Aditionally set alpha
|
||||
* @param layer_selector LayerSelector object
|
||||
* @param palette Color palette to use
|
||||
* @param global_alpha Additional alpha value that is applied to all layers
|
||||
* @param global_alpha Additional alpha value that is applied to all layers. Must be > 0
|
||||
*/
|
||||
void layer_selector_auto_color_layers(LayerSelector *layer_selector, ColorPalette *palette, double global_alpha);
|
||||
|
||||
/**
|
||||
* @brief Auto name all layers in the layer selector.
|
||||
*
|
||||
* This functions sets the name of the layer equal to its number.
|
||||
* The \p overwrite parameter specifies if already set layer names are overwritten.
|
||||
*
|
||||
* @param layer_selector LayerSelector
|
||||
* @param overwrite Overwrite existing layer names
|
||||
*/
|
||||
void layer_selector_auto_name_layers(LayerSelector *layer_selector, gboolean overwrite);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __LAYER_SELECTOR_H__ */
|
||||
|
@ -857,4 +857,34 @@ ret_free_le_list:
|
||||
g_list_free(le_list);
|
||||
}
|
||||
|
||||
void layer_selector_auto_name_layers(LayerSelector *layer_selector, gboolean overwrite)
|
||||
{
|
||||
GList *le_list;
|
||||
GList *le_list_ptr;
|
||||
LayerElement *le;
|
||||
const char *old_layer_name;
|
||||
GString *new_layer_name;
|
||||
|
||||
g_return_if_fail(LAYER_IS_SELECTOR(layer_selector));
|
||||
|
||||
new_layer_name = g_string_new_len(NULL, 10);
|
||||
le_list = gtk_container_get_children(GTK_CONTAINER(layer_selector->list_box));
|
||||
|
||||
for (le_list_ptr = le_list; le_list_ptr != NULL; le_list_ptr = g_list_next(le_list_ptr)) {
|
||||
le = LAYER_ELEMENT(le_list_ptr->data);
|
||||
if (!le)
|
||||
continue;
|
||||
old_layer_name = layer_element_get_name(le);
|
||||
|
||||
/* Check if layer name is empty or may be overwritten */
|
||||
if (!old_layer_name || *old_layer_name == '\0' || overwrite) {
|
||||
g_string_printf(new_layer_name, "Layer %d", layer_element_get_layer(le));
|
||||
layer_element_set_name(le, new_layer_name->str);
|
||||
}
|
||||
}
|
||||
|
||||
g_string_free(new_layer_name, TRUE);
|
||||
g_list_free(le_list);
|
||||
}
|
||||
|
||||
/** @} */
|
||||
|
2
main.c
2
main.c
@ -92,7 +92,7 @@ static void app_about(GSimpleAction *action, GVariant *parameter, gpointer user_
|
||||
GString *comment_text;
|
||||
|
||||
comment_text = g_string_new("gds-render is a tool fo rendering GDS2 layout files into vector graphics.");
|
||||
g_string_append_printf(comment_text, "\n\n Full git commit: %s", _app_git_commit);
|
||||
g_string_append_printf(comment_text, "\n\nFull git commit: %s", _app_git_commit);
|
||||
|
||||
builder = gtk_builder_new_from_resource("/gui/about.glade");
|
||||
dialog = GTK_DIALOG(gtk_builder_get_object(builder, "about-dialog"));
|
||||
|
@ -2,6 +2,11 @@
|
||||
<!-- Generated with glade 3.22.1 -->
|
||||
<interface>
|
||||
<requires lib="gtk+" version="3.20"/>
|
||||
<object class="GtkImage" id="auto-name-img">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="stock">gtk-edit</property>
|
||||
</object>
|
||||
<object class="GtkImage" id="color-img">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
@ -234,6 +239,20 @@
|
||||
<property name="position">3</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton" id="button-auto-name">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">True</property>
|
||||
<property name="image">auto-name-img</property>
|
||||
<property name="always_show_image">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">4</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
|
Loading…
Reference in New Issue
Block a user